-
-
Notifications
You must be signed in to change notification settings - Fork 109
Description
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_autoscalersetting - Cannot convert existing tables from
PAY_PER_REQUESTtoPROVISIONEDbilling 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_REQUESTmode - Need to convert to
PROVISIONEDwith specific capacity - Set
billing_mode = "PROVISIONED"andenable_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 = falsewith 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
- Module version:
v0.37.0
Additional Context
This is particularly problematic when:
- Migrating existing tables from on-demand to provisioned billing
- Using external autoscaling tools (e.g., separate
dynamodb-autoscalermodule) - 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.