When updating a DynamoDB table with one or more global secondary indexes, changing billing_mode from PAY_PER_REQUEST to PROVISIONED, the update fails to apply. Terraform tries to create a new GSI with given read & write capacity, while the existing GSI is left with "0" capacity which makes it fail due to invalid parameter (ProvisionedThroughput must be specified when BillingMode is PROVISIONED).
Terraform v0.11.10
provider.aws v1.57.0
resource "aws_dynamodb_table" "users" {
name = "users"
billing_mode = "PROVISIONED"
read_capacity = "10"
write_capacity = "10"
hash_key = "uuid"
attribute {
name = "uuid"
type = "S"
}
attribute {
name = "nick_lower"
type = "S"
}
attribute {
name = "discriminator"
type = "S"
}
global_secondary_index {
name = "username"
hash_key = "nick_lower"
range_key = "discriminator"
write_capacity = "10"
read_capacity = "10"
projection_type = "INCLUDE"
non_key_attributes = [ "nick" ]
}
}
Billing mode should have changed along with read & write capacities for the table and global secondary index(es).
terraform apply exits with an error.
Output:
aws_dynamodb_table.users: Modifying... (ID: users)
billing_mode: "PAY_PER_REQUEST" => "PROVISIONED"
global_secondary_index.3667214579.hash_key: "nick_lower" => ""
global_secondary_index.3667214579.name: "username" => ""
global_secondary_index.3667214579.non_key_attributes.#: "1" => "0"
global_secondary_index.3667214579.non_key_attributes.0: "nick" => ""
global_secondary_index.3667214579.projection_type: "INCLUDE" => ""
global_secondary_index.3667214579.range_key: "discriminator" => ""
global_secondary_index.3667214579.read_capacity: "0" => "0"
global_secondary_index.3667214579.write_capacity: "0" => "0"
global_secondary_index.3853577238.hash_key: "" => "nick_lower"
global_secondary_index.3853577238.name: "" => "username"
global_secondary_index.3853577238.non_key_attributes.#: "0" => "1"
global_secondary_index.3853577238.non_key_attributes.0: "" => "nick"
global_secondary_index.3853577238.projection_type: "" => "INCLUDE"
global_secondary_index.3853577238.range_key: "" => "discriminator"
global_secondary_index.3853577238.read_capacity: "" => "10"
global_secondary_index.3853577238.write_capacity: "" => "10"
read_capacity: "0" => "10"
write_capacity: "0" => "10"
Releasing state lock. This may take a few moments...
Error: Error applying plan:
1 error(s) occurred:
* aws_dynamodb_table.users: 1 error(s) occurred:
* aws_dynamodb_table.users: Error updating DynamoDB Table (users) billing mode: ValidationException: One or more parameter values were invalid: ProvisionedThroughput must be specified when BillingMode is PROVISIONED
status code: 400, request id: E1T2ARB74U6K2FFET5M2U878MJVV4KQNSO5AEMVJF66Q9ASUAAJG
PAY_PER_REQUEST as billing_modeaws_dynamodb_table configuration from PAY_PER_REQUEST to PROVISIONEDterraform applyI am double checking this against the currently unreleased fix we merged yesterday (#7363) via additional acceptance testing and will report back shortly.
It looks like GSIs still have a similar issue when going PAY_BY_REQUEST to PROVISIONED:
--- FAIL: TestAccAWSDynamoDbTable_BillingModeUpdateWithGSI (141.28s)
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 updating DynamoDB Table (TerraformTestTable--1308651219154584046) billing mode: ValidationException: One or more parameter values were invalid: ProvisionedThroughput must be specified for index: TestTableGSI
I will submit a fix later today.
Fix submitted: #7453
The fix for this has been merged and will release with version 1.59.0 of the Terraform AWS Provider, likely middle of this week. 👍
This has been released in version 1.59.0 of the 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!