-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add tag on create for aws_sqs_queue resource #10156
add tag on create for aws_sqs_queue resource #10156
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, @kterada0509 🚀 While the changes look okay, it looks like this functionality is not working properly in AWS GovCloud (US) yet and unfortunately breaking in a way we don't usually want to workaround with 500 Internal Server Errors:
2019/09/24 10:56:19 [DEBUG] [aws-sdk-go] DEBUG: Retrying Request sqs/CreateQueue, attempt 12
2019/09/24 10:56:19 [DEBUG] [aws-sdk-go] DEBUG: Request sqs/CreateQueue Details:
---[ REQUEST POST-SIGN ]-----------------------------
POST / HTTP/1.1
Host: sqs.us-gov-west-1.amazonaws.com
...
Action=CreateQueue&Attribute.1.Name=MaximumMessageSize&Attribute.1.Value=262144&Attribute.2.Name=MessageRetentionPeriod&Attribute.2.Value=345600&Attribute.3.Name=VisibilityTimeout&Attribute.3.Value=30&QueueName=sqs-queue-q6fiozksv7&Tag.1.Key=Environment&Tag.1.Value=production&Tag.2.Key=Usage&Tag.2.Value=original&Version=2012-11-05
-----------------------------------------------------
2019/09/24 10:56:19 [DEBUG] [aws-sdk-go] DEBUG: Response sqs/CreateQueue Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 500 Internal Server Error
...
2019/09/24 10:56:19 [DEBUG] [aws-sdk-go] <?xml version="1.0"?><ErrorResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"><Error><Type>Receiver</Type><Code>InternalError</Code><Message>We encountered an internal error. Please try again.</Message><Detail/></Error><RequestId>5c1fe0da-0bdf-53a8-9432-b6de3b0cbcd3</RequestId></ErrorResponse>
2019/09/24 10:56:19 [DEBUG] [aws-sdk-go] DEBUG: Validate Response sqs/CreateQueue failed, attempt 12/25, error InternalError: We encountered an internal error. Please try again.
status code: 500, request id: 5c1fe0da-0bdf-53a8-9432-b6de3b0cbcd3
The announcement does specifically call out:
now available in all commercial AWS Regions.
To maintain compatibility with other AWS partitions, this unfortunately looks we will need to ensure we're in a commercial region or otherwise fallback to the old logic. I left suggestions below. Please reach out if you have any questions.
Output from acceptance testing in AWS Commercial:
--- PASS: TestAccAWSSQSQueue_FIFOExpectNameError (5.08s)
--- PASS: TestAccAWSSQSQueue_ExpectContentBasedDeduplicationError (5.23s)
--- PASS: TestAccAWSSQSQueue_FIFO (14.00s)
--- PASS: TestAccAWSSQSQueue_FIFOWithContentBasedDeduplication (14.36s)
--- PASS: TestAccAWSSQSQueue_namePrefix (14.37s)
--- PASS: TestAccAWSSQSQueue_namePrefix_fifo (14.37s)
--- PASS: TestAccAWSSQSQueue_Encryption (14.42s)
--- PASS: TestAccAWSSQSQueue_redrivePolicy (17.24s)
--- PASS: TestAccAWSSQSQueue_policy (19.11s)
--- PASS: TestAccAWSSQSQueue_Policybasic (19.21s)
--- PASS: TestAccAWSSQSQueue_basic (31.64s)
--- PASS: TestAccAWSSQSQueue_tags (31.89s)
--- PASS: TestAccAWSSQSQueue_queueDeletedRecently (92.05s)
aws/resource_aws_sqs_queue.go
Outdated
@@ -170,6 +170,10 @@ func resourceAwsSqsQueueCreate(d *schema.ResourceData, meta interface{}) error { | |||
QueueName: aws.String(name), | |||
} | |||
|
|||
if v, ok := d.GetOk("tags"); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if v, ok := d.GetOk("tags"); ok { | |
// Tag-on-create is currently only supported in AWS Commercial | |
if v, ok := d.GetOk("tags"); ok && meta.(*AWSClient).partition == endpoints.AwsPartitionID { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed.
aws/resource_aws_sqs_queue.go
Outdated
@@ -215,7 +219,7 @@ func resourceAwsSqsQueueCreate(d *schema.ResourceData, meta interface{}) error { | |||
|
|||
d.SetId(aws.StringValue(output.QueueUrl)) | |||
|
|||
return resourceAwsSqsQueueUpdate(d, meta) | |||
return resourceAwsSqsQueueRead(d, meta) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return resourceAwsSqsQueueRead(d, meta) | |
// Tag-on-create is currently only supported in AWS Commercial | |
if meta.(*AWSClient).partition == endpoints.AwsPartitionID { | |
return resourceAwsSqsQueueRead(d, meta) | |
} else { | |
return resourceAwsSqsQueueUpdate(d, meta) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed.
7077980
to
606f0ad
Compare
Re-run acctest.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates, @kterada0509 🚀
Output from acceptance testing in AWS Commercial:
--- PASS: TestAccAWSSQSQueue_FIFOExpectNameError (6.08s)
--- PASS: TestAccAWSSQSQueue_ExpectContentBasedDeduplicationError (6.23s)
--- PASS: TestAccAWSSQSQueue_FIFO (14.78s)
--- PASS: TestAccAWSSQSQueue_namePrefix_fifo (15.02s)
--- PASS: TestAccAWSSQSQueue_FIFOWithContentBasedDeduplication (15.19s)
--- PASS: TestAccAWSSQSQueue_Encryption (15.42s)
--- PASS: TestAccAWSSQSQueue_namePrefix (15.63s)
--- PASS: TestAccAWSSQSQueue_redrivePolicy (18.64s)
--- PASS: TestAccAWSSQSQueue_Policybasic (20.19s)
--- PASS: TestAccAWSSQSQueue_policy (20.24s)
--- PASS: TestAccAWSSQSQueue_basic (32.75s)
--- PASS: TestAccAWSSQSQueue_tags (32.95s)
--- PASS: TestAccAWSSQSQueue_queueDeletedRecently (92.70s)
Output from acceptance testing in AWS GovCloud (US) (turns out SQS resource tagging isn't supported at all in GovCloud, but at least it errors immediately now):
--- PASS: TestAccAWSSQSQueue_ExpectContentBasedDeduplicationError (7.35s)
--- PASS: TestAccAWSSQSQueue_FIFOExpectNameError (7.54s)
--- FAIL: TestAccAWSSQSQueue_tags (10.83s)
testing.go:569: Step 0 error: errors during apply:
Error: AWS.SimpleQueueService.UnsupportedOperation: Tag queue in TagQueue operation are not supported.
status code: 400, request id: 7ec0febb-c893-526c-8a48-a8bff7a8d585
on /var/folders/v0/_d108fkx1pbbg4_sh864_7740000gn/T/tf-test491518323/main.tf line 2:
(source code not available)
--- PASS: TestAccAWSSQSQueue_namePrefix (18.94s)
--- PASS: TestAccAWSSQSQueue_namePrefix_fifo (19.07s)
--- PASS: TestAccAWSSQSQueue_Encryption (19.23s)
--- PASS: TestAccAWSSQSQueue_FIFO (20.09s)
--- PASS: TestAccAWSSQSQueue_FIFOWithContentBasedDeduplication (21.17s)
--- PASS: TestAccAWSSQSQueue_Policybasic (24.20s)
--- PASS: TestAccAWSSQSQueue_redrivePolicy (25.04s)
--- PASS: TestAccAWSSQSQueue_policy (25.15s)
--- PASS: TestAccAWSSQSQueue_queueDeletedRecently (98.77s)
This has been released in version 2.30.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Closes #9850
Release note for CHANGELOG:
Output from acceptance testing: