Describe the Bug
Problem Description
The aws_dynamodb_table.default resource has an unconditional lifecycle rule that ignores changes to read_capacity and write_capacity:
lifecycle {
ignore_changes = [
read_capacity,
write_capacity
]
}
This prevents Terraform from managing capacity in scenarios where autoscaling is not enabled but we still need to set/update capacity values.
Current Behavior
- Capacity changes are always ignored, regardless of
enable_autoscaler setting
- Cannot convert existing tables from
PAY_PER_REQUEST to PROVISIONED billing mode
- Cannot set initial capacity values when
enable_autoscaler = false
- Terraform plan shows billing mode change but capacity values are missing, leading to AWS API errors
Use Case
Scenario 1: Converting PAY_PER_REQUEST → PROVISIONED
- Existing table in
PAY_PER_REQUEST mode
- Need to convert to
PROVISIONED with specific capacity
- Set
billing_mode = "PROVISIONED" and enable_autoscaler = false
- Result: Terraform plan shows billing mode change but capacity is ignored → AWS rejects update
Scenario 2: Fixed capacity without autoscaling
- Need provisioned capacity but want to manage it manually (not via autoscaling)
- Set
enable_autoscaler = false with specific capacity values
- Result: Initial table creation works, but updates to capacity are ignored
Proposed Solution
Make the lifecycle rule conditional based on the enable_autoscaler variable:
lifecycle {
ignore_changes = var.enable_autoscaler ? [
read_capacity,
write_capacity
] : []
}
This way:
- ✅ When
enable_autoscaler = true: Capacity is ignored (autoscaling manages it)
- ✅ When
enable_autoscaler = false: Capacity is managed by Terraform (can be set/updated normally)
Expected Behavior
Capacity should only be ignored when autoscaling is actively enabled (i.e., when enable_autoscaler = true). When autoscaling is disabled, Terraform should be able to manage capacity values normally.
Steps to Reproduce
Example Configuration
**Current behavior (broken):**
module "dynamodb_table" {
source = "cloudposse/dynamodb/aws"
billing_mode = "PROVISIONED"
enable_autoscaler = false
autoscale_min_read_capacity = 255
autoscale_min_write_capacity = 705
# ... other config
}
Plan shows billing mode change but capacity values are ignored → AWS update fails
With proposed fix:
Same configuration would work correctly, allowing Terraform to set capacity values.
Screenshots
No response
Environment
Additional Context
This is particularly problematic when:
- Migrating existing tables from on-demand to provisioned billing
- Using external autoscaling tools (e.g., separate
dynamodb-autoscaler module)
- Needing fixed capacity without AWS Application Auto Scaling
The current unconditional ignore prevents legitimate capacity management scenarios.
Proposed PR
I'm happy to submit a PR with this fix if the maintainers agree this is the desired behavior.
Describe the Bug
Problem Description
The
aws_dynamodb_table.defaultresource has an unconditional lifecycle rule that ignores changes toread_capacityandwrite_capacity:This prevents Terraform from managing capacity in scenarios where autoscaling is not enabled but we still need to set/update capacity values.
Current Behavior
enable_autoscalersettingPAY_PER_REQUESTtoPROVISIONEDbilling modeenable_autoscaler = falseUse Case
Scenario 1: Converting PAY_PER_REQUEST → PROVISIONED
PAY_PER_REQUESTmodePROVISIONEDwith specific capacitybilling_mode = "PROVISIONED"andenable_autoscaler = falseScenario 2: Fixed capacity without autoscaling
enable_autoscaler = falsewith specific capacity valuesProposed Solution
Make the lifecycle rule conditional based on the
enable_autoscalervariable:This way:
enable_autoscaler = true: Capacity is ignored (autoscaling manages it)enable_autoscaler = false: Capacity is managed by Terraform (can be set/updated normally)Expected Behavior
Capacity should only be ignored when autoscaling is actively enabled (i.e., when
enable_autoscaler = true). When autoscaling is disabled, Terraform should be able to manage capacity values normally.Steps to Reproduce
Example Configuration
Plan shows billing mode change but capacity values are ignored → AWS update fails
With proposed fix:
Same configuration would work correctly, allowing Terraform to set capacity values.
Screenshots
No response
Environment
v0.37.0Additional Context
This is particularly problematic when:
dynamodb-autoscalermodule)The current unconditional ignore prevents legitimate capacity management scenarios.
Proposed PR
I'm happy to submit a PR with this fix if the maintainers agree this is the desired behavior.