🚀 Enhancements
feat: adding the option to disable ttl once it was enable before @alfredo-gil (#111)
what
The change aims to be able to disable the TTL once a dynamodb table was enabled before.
why
- With the current dynamic block on the TTL option inside the
aws_dynamodb_table
resource if you change thevar.ttl_enabled = false
there are no changes on the infrastructure and the TTL is not disabled:
No changes. Your infrastructure matches the configuration.
- With this change you can disable the TTL on a dynamodb table that had it enabled before following this process:
- Change the
var.ttl_enabled = false
Do the plan and apply - Change later the
var.ttl_attribute=""
or leave it empty to consolidate the state. If you don't do this second change your plan is going to say something like this and if you try to apply you will have an error...
~ resource "aws_dynamodb_table" "default" {
id = "test"
name = "test"
tags = {
...
}
# (9 unchanged attributes hidden)
~ ttl {
+ attribute_name = "ttl"
# (1 unchanged attribute hidden)
}
# (3 unchanged blocks hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions in workspace "test"?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
module.dynamodb["test"].module.dynamodb_table.aws_dynamodb_table.default[0]: Modifying... [id=test]
╷
│ Error: updating Amazon DynamoDB Table (test): updating Time To Live: ValidationException: TimeToLive is already disabled
│ status code: 400, request id: XXXXXXXXXXXXXXXXXXXXXX
│
│ with module.dynamodb["test"].module.dynamodb_table.aws_dynamodb_table.default[0],
│ on .terraform/modules/dynamodb.dynamodb_table/main.tf line 46, in resource "aws_dynamodb_table" "default":
│ 46: resource "aws_dynamodb_table" "default" {
│
references
- This is the origin of the issue hashicorp/terraform-provider-aws#10304