Skip to content

Unconditional lifecycle ignore_changes prevents capacity updates when autoscaling is disabled #145

@msarmadi

Description

@msarmadi

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

  • Module version: v0.37.0

Additional Context

This is particularly problematic when:

  1. Migrating existing tables from on-demand to provisioned billing
  2. Using external autoscaling tools (e.g., separate dynamodb-autoscaler module)
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug🐛 An issue with the system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions