-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 support for tag-on-create for dynamodb tables #8469
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 @sunilkumarmohanty! Looks good other than the adjustments required for AWS GovCloud (US) which will be handled on merge. 🚀
After the mentioned code changes:
Output from AWS Standard acceptance testing:
--- PASS: TestAccAWSDynamoDbTable_streamSpecificationValidation (5.74s)
--- PASS: TestAccAWSDynamoDbTable_attributeUpdateValidation (6.49s)
--- PASS: TestAccAWSDynamoDbTable_basic (25.94s)
--- PASS: TestAccAWSDynamoDbTable_streamSpecification (74.28s)
--- PASS: TestAccAWSDynamoDbTable_gsiUpdateCapacity (112.39s)
--- PASS: TestAccAWSDynamoDbTable_disappears (112.60s)
--- PASS: TestAccAWSDynamoDbTable_Ttl_Enabled (120.12s)
--- PASS: TestAccAWSDynamoDbTable_Ttl_Disabled (129.84s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_PayPerRequestToProvisioned (142.69s)
--- PASS: TestAccAWSDynamoDbTable_tags (144.83s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_GSI_PayPerRequestToProvisioned (173.16s)
--- PASS: TestAccAWSDynamoDbTable_importBasic (176.86s)
--- PASS: TestAccAWSDynamoDbTable_importTags (171.77s)
--- PASS: TestAccAWSDynamoDbTable_disappears_PayPerRequestWithGSI (182.13s)
--- PASS: TestAccAWSDynamoDbTable_encryption (234.29s)
--- PASS: TestAccAWSDynamoDbTable_enablePitr (371.32s)
--- PASS: TestAccAWSDynamoDbTable_gsiUpdateNonKeyAttributes (392.32s)
--- PASS: TestAccAWSDynamoDbTable_extended (399.61s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_GSI_ProvisionedToPayPerRequest (652.60s)
--- PASS: TestAccAWSDynamoDbTable_gsiUpdateOtherAttributes (709.56s)
--- PASS: TestAccAWSDynamoDbTable_attributeUpdate (710.63s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_ProvisionedToPayPerRequest (939.12s)
Output from AWS GovCloud (US) acceptance testing (test failures unrelated -- we really need a PreCheck
for billing mode support):
--- PASS: TestAccAWSDynamoDbTable_streamSpecificationValidation (7.34s)
--- PASS: TestAccAWSDynamoDbTable_attributeUpdateValidation (8.56s)
--- FAIL: TestAccAWSDynamoDbTable_BillingMode_PayPerRequestToProvisioned (11.42s)
testing.go:568: Step 0 error: errors during apply:
Error: error creating DynamoDB Table: ValidationException: One or more parameter values were invalid: Missing required parameter in input: "ProvisionedThroughput"
...
--- FAIL: TestAccAWSDynamoDbTable_BillingMode_GSI_PayPerRequestToProvisioned (11.58s)
testing.go:568: Step 0 error: errors during apply:
Error: error creating DynamoDB Table: ValidationException: One or more parameter values were invalid: Missing required parameter in input: "ProvisionedThroughput"
...
--- FAIL: TestAccAWSDynamoDbTable_disappears_PayPerRequestWithGSI (8.16s)
testing.go:568: Step 0 error: errors during apply:
Error: error creating DynamoDB Table: ValidationException: One or more parameter values were invalid: Missing required parameter in input: "ProvisionedThroughput"
...
--- FAIL: TestAccAWSDynamoDbTable_BillingMode_GSI_ProvisionedToPayPerRequest (83.58s)
testing.go:568: Step 1 error: errors during apply:
Error: error updating DynamoDB Table (TerraformTestTable--1046408333877050005): ValidationException: One or more parameter values were invalid: Unsupported input parameter BillingMode
...
--- PASS: TestAccAWSDynamoDbTable_disappears (117.29s)
--- PASS: TestAccAWSDynamoDbTable_basic (122.23s)
--- FAIL: TestAccAWSDynamoDbTable_BillingMode_ProvisionedToPayPerRequest (128.19s)
testing.go:568: Step 1 error: errors during apply:
Error: error updating DynamoDB Table (TerraformTestTable--2469300233617270204): ValidationException: One or more parameter values were invalid: Unsupported input parameter BillingMode
...
--- PASS: TestAccAWSDynamoDbTable_Ttl_Enabled (128.48s)
--- PASS: TestAccAWSDynamoDbTable_tags (149.84s)
--- PASS: TestAccAWSDynamoDbTable_importBasic (153.64s)
--- PASS: TestAccAWSDynamoDbTable_streamSpecification (163.73s)
--- FAIL: TestAccAWSDynamoDbTable_extended (167.14s)
testing.go:568: Step 1 error: errors during apply:
Error: error updating DynamoDB Table (TerraformTestTable--9088649623966159339): ValidationException: One or more parameter values were invalid: Unsupported input parameter BillingMode
...
--- PASS: TestAccAWSDynamoDbTable_importTags (184.51s)
--- FAIL: TestAccAWSDynamoDbTable_gsiUpdateCapacity (187.35s)
testing.go:568: Step 1 error: errors during apply:
Error: error updating DynamoDB Table (tf-acc-test-9zdhg0lxlw): ValidationException: One or more parameter values were invalid: Unsupported input parameter BillingMode
...
--- PASS: TestAccAWSDynamoDbTable_encryption (251.59s)
--- PASS: TestAccAWSDynamoDbTable_Ttl_Disabled (287.78s)
--- PASS: TestAccAWSDynamoDbTable_gsiUpdateNonKeyAttributes (322.48s)
--- PASS: TestAccAWSDynamoDbTable_attributeUpdate (617.31s)
--- PASS: TestAccAWSDynamoDbTable_gsiUpdateOtherAttributes (619.70s)
--- PASS: TestAccAWSDynamoDbTable_enablePitr (968.79s)
if d.HasChange("tags") { | ||
if err := setTagsDynamoDb(conn, d); err != nil { | ||
return fmt.Errorf("error updating DynamoDB Table (%s) tags: %s", d.Id(), err) | ||
if !d.IsNewResource() { |
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.
It appears that the Create
function returns the Read
function instead of the Update
function (as is best practice) so this check is extraneous. 👍
req := &dynamodb.CreateTableInput{ | ||
TableName: aws.String(d.Get("name").(string)), | ||
BillingMode: aws.String(d.Get("billing_mode").(string)), | ||
KeySchema: expandDynamoDbKeySchema(keySchemaMap), | ||
Tags: tags, |
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.
It appears that AWS GovCloud (US) has unfortunately not been updated for tag-on-create support yet, returning the following error:
--- FAIL: TestAccAWSDynamoDbTable_basic (9.68s)
testing.go:568: Step 0 error: errors during apply:
Error: error creating DynamoDB Table: ValidationException: Unsupported input parameter Tags
To workaround this error while automatically supporting tag-on-create without code change in the future, we can catch this specific error during our resource.Retry()
logic, set the parameter to nil
, and perform a similar tagging API call after creation as it did previously. e.g.
var requiresTagging bool
// ...
// AWS GovCloud (US) and others may reply with the following until their API is updated:
// ValidationException: Unsupported input parameter Tags
if isAWSErr(err, "ValidationException", "Unsupported input parameter Tags") {
req.Tags = nil
requiresTagging = true
return resource.RetryableError(err)
}
// ...
if requiresTagging {
if err := setTagsDynamoDb(conn, d); err != nil {
return fmt.Errorf("error adding DynamoDB Table (%s) tags: %s", d.Id(), err)
}
}
This has been released in version 2.11.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
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! |
Fixes #8442
Changes proposed in this pull request:
Output from acceptance testing: