terraform-provider-aws
terraform-provider-aws copied to clipboard
DynamoDB Table with replica v2019.11.21 and PAY_PER_REQUEST makes GSI modifications in a loop
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Terraform Version
Terraform v0.12.24
- provider.aws v2.58.0
- provider.template v2.1.2
Affected Resource(s)
- aws_dynamodb_table
Terraform Configuration Files
resource "aws_dynamodb_table" "sessions_us-west-2" {
name = "sessions"
billing_mode = "PAY_PER_REQUEST"
hash_key = "SessionId"
attribute {
name = "SessionId"
type = "S"
}
attribute {
name = "UserId"
type = "N"
}
attribute {
name = "ExpiresAt"
type = "N"
}
global_secondary_index {
name = "UserSessionsIndex"
hash_key = "UserId"
range_key = "ExpiresAt"
projection_type = "INCLUDE"
non_key_attributes = ["UserId", "ExpiresAt", "SessionId"]
}
ttl {
attribute_name = "ExpiresAt"
enabled = true
}
server_side_encryption {
enabled = true
}
stream_enabled = true
stream_view_type = "NEW_AND_OLD_IMAGES"
replica {
region_name = "eu-west-1"
}
}
Expected Behavior
terraform apply should not do any changes
Actual Behavior
Every time I run, it wants to update the GSI with the same data..
+ global_secondary_index {
+ hash_key = "UserId"
+ name = "UserSessionsIndex"
+ non_key_attributes = [
+ "UserId",
+ "ExpiresAt",
+ "SessionId",
]
+ projection_type = "INCLUDE"
+ range_key = "ExpiresAt"
+ read_capacity = 0
+ write_capacity = 0
}
- global_secondary_index {
- hash_key = "UserId" -> null
- name = "UserSessionsIndex" -> null
- non_key_attributes = [
- "UserId",
- "ExpiresAt",
- "SessionId",
] -> null
- projection_type = "INCLUDE" -> null
- range_key = "ExpiresAt" -> null
- read_capacity = 0 -> null
- write_capacity = 0 -> null
}
I tried specifying the read_capacity/write_capacity as that was the only missing thing I saw, which might be causing this, but it doesn't help, still does the same with this:
global_secondary_index {
name = "UserSessionsIndex"
hash_key = "UserId"
range_key = "ExpiresAt"
projection_type = "INCLUDE"
non_key_attributes = ["UserId", "ExpiresAt", "SessionId"]
read_capacity = 0
write_capacity = 0
}
Note that it should not be required to specify these as we are using PAY_PER_REQUEST billing_mode.
Steps to Reproduce
-
terraform apply
, twice
References
- #12342 / cc @cmonty (thanks for the implementation btw, this came just as I needed it! :)
Ah thanks that one has a workaround in https://github.com/terraform-providers/terraform-provider-aws/issues/3828#issuecomment-569041696 👍
Hi Y'all, we are currently tracking this issue alongside #671.
We've added #671 to our team's prioritization board and are planning to address it and its related PRs in a near-term release. As this issue is related, we'll keep an eye on this and check back to see if our solution to #671 fixes/closes this as well.
Thanks!
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.
If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.