From 5e5762c28c22a2b5d99b1885180015452b310bef Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Tue, 8 Jan 2019 09:02:57 -0500 Subject: [PATCH] resource/aws_dynamodb_table: Fix table creation in GovCloud (US) and China due to missing BillingMode support Previous output from acceptance testing (AWS GovCloud (US), all aws_dynamodb_table tests): ``` --- FAIL: TestAccAWSDynamoDbTable_basic (0.39s) testing.go:538: Step 0 error: Error applying: 1 error occurred: * aws_dynamodb_table.basic-dynamodb-table: 1 error occurred: * aws_dynamodb_table.basic-dynamodb-table: ValidationException: One or more parameter values were invalid: Unsupported input parameter BillingMode ``` Output from acceptance testing (AWS GovCloud (US), no new failures from pre-BillingMode): ``` --- PASS: TestAccAWSDynamoDbTable_streamSpecificationValidation (3.64s) --- PASS: TestAccAWSDynamoDbTable_attributeUpdateValidation (5.13s) --- FAIL: TestAccAWSDynamoDbTable_encryption (5.43s) testing.go:538: Step 0 error: Error applying: 1 error occurred: * aws_dynamodb_table.basic-dynamodb-table: 1 error occurred: * aws_dynamodb_table.basic-dynamodb-table: error creating DynamoDB Table: ValidationException: One or more parameter values were invalid: Unsupported input parameter SSESpecification status code: 400, request id: F6OSK8MN7T1JOG2S5E30GSHN4VVV4KQNSO5AEMVJF66Q9ASUAAJG --- PASS: TestAccAWSDynamoDbTable_basic (25.22s) --- PASS: TestAccAWSDynamoDbTable_streamSpecification (41.12s) --- PASS: TestAccAWSDynamoDbTable_importTags (47.65s) --- PASS: TestAccAWSDynamoDbTable_ttl (56.96s) --- FAIL: TestAccAWSDynamoDbTable_enablePitr (61.74s) testing.go:538: Step 1 error: Error applying: 1 error occurred: * aws_dynamodb_table.basic-dynamodb-table: 1 error occurred: * aws_dynamodb_table.basic-dynamodb-table: UnknownOperationException: Unknown operation exception status code: 400, request id: 0DN6K5DCG70T8SFDVEH7B0GJ9BVV4KQNSO5AEMVJF66Q9ASUAAJG --- PASS: TestAccAWSDynamoDbTable_tags (72.81s) --- PASS: TestAccAWSDynamoDbTable_importBasic (74.31s) --- PASS: TestAccAWSDynamoDbTable_gsiUpdateCapacity (105.10s) --- PASS: TestAccAWSDynamoDbTable_importTimeToLive (106.13s) --- FAIL: TestAccAWSDynamoDbTable_BillingMode (116.25s) testing.go:538: Step 1 error: Error applying: 1 error occurred: * aws_dynamodb_table.basic-dynamodb-table: 1 error occurred: * aws_dynamodb_table.basic-dynamodb-table: error creating DynamoDB Table: ValidationException: One or more parameter values were invalid: Missing required parameter in input: "ProvisionedThroughput" status code: 400, request id: 2BEOP0E6AD39707F43EEMDED1FVV4KQNSO5AEMVJF66Q9ASUAAJG --- PASS: TestAccAWSDynamoDbTable_gsiUpdateNonKeyAttributes (289.91s) --- PASS: TestAccAWSDynamoDbTable_extended (292.16s) --- PASS: TestAccAWSDynamoDbTable_attributeUpdate (586.40s) --- PASS: TestAccAWSDynamoDbTable_gsiUpdateOtherAttributes (589.72s) ``` --- aws/resource_aws_dynamodb_table.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_dynamodb_table.go b/aws/resource_aws_dynamodb_table.go index c4d7eab409a..4dc7e8d2893 100644 --- a/aws/resource_aws_dynamodb_table.go +++ b/aws/resource_aws_dynamodb_table.go @@ -362,13 +362,19 @@ func resourceAwsDynamoDbTableCreate(d *schema.ResourceData, meta interface{}) er if isAWSErr(err, dynamodb.ErrCodeLimitExceededException, "indexed tables that can be created simultaneously") { return resource.RetryableError(err) } + // AWS GovCloud (US) and others may reply with the following until their API is updated: + // ValidationException: One or more parameter values were invalid: Unsupported input parameter BillingMode + if isAWSErr(err, "ValidationException", "Unsupported input parameter BillingMode") { + req.BillingMode = nil + return resource.RetryableError(err) + } return resource.NonRetryableError(err) } return nil }) if err != nil { - return err + return fmt.Errorf("error creating DynamoDB Table: %s", err) } d.SetId(*output.TableDescription.TableName)