Ignore autoscaling changes
For platform engineers deciding whether to apply lifecycle_ignore_autoscaling_changes: what it changes, how to enable it, and how to check it worked.
Adds ignore_changes = [read_capacity, write_capacity] to DynamoDB tables. Prevents Terraform from reverting autoscaler adjustments.
What this rule does
Adds a lifecycle { ignore_changes = [...] } block to each matching resource. Terraform and OpenTofu will ignore external changes to the listed attributes on subsequent plans.
Ignored attributes: read_capacity, write_capacity
Affected resources
| Resource | Service | Why |
|---|---|---|
aws_dynamodb_table | Amazon DynamoDB | Capacity attributes managed by Application Auto Scaling |
Before and after
Before (a module without the change):
resource "aws_dynamodb_table" "this" {
# ... resource configuration ...
tags = var.tags
}After (with Ignore autoscaling changes applied):
resource "aws_dynamodb_table" "this" {
# ... resource configuration ...
tags = var.tags
lifecycle {
ignore_changes = [read_capacity, write_capacity]
}
}The only change is the rule transformation. All existing arguments, outputs, and module behavior remain identical.
The example above is illustrative. To see this rule run for real, open it in the
Rules Playground: it applies lifecycle_ignore_autoscaling_changes to a
reviewed upstream module that declares the resources this rule targets, and
shows the diff the registry would serve. No account needed.
Why this rule exists
DynamoDB tables with auto scaling enabled have their read and write capacity adjusted continuously by AWS Application Auto Scaling. Terraform sees these changes on every plan and proposes reverting them.
The fix is straightforward (add ignore_changes) but requires modifying every DynamoDB resource in every module. With upstream terraform-aws-modules, you cannot add this without forking.
Related Terraform and OpenTofu issues
| Repository | Issue | Title |
|---|---|---|
| hashicorp/terraform | #27360 | A method to override configuration and meta arguments within a module |
Limitations this rule answers
Per-module pages under Workarounds where this rule is the answer, each with the native workaround first and the diff the rule makes:
Default configuration
These are the values the rule ships with. Parameters never travel in a module source URL, so a rule named there runs with exactly these defaults. Your organization sets them per rule, in its Baseline or in a ruleset.
| Parameter | Type | Default | Description |
|---|---|---|---|
ignore_changes | list(string) | ["read_capacity", "write_capacity"] | Lifecycle attributes to ignore |
resource_types | list(string) | ["aws_dynamodb_table"] | Target resource type patterns |
The HCL this rule is written in, with its parameters and the transformers it runs, is published at lifecycle_ignore_autoscaling_changes.
How to enable
On a framework host, add the rule on top of your organization's Baseline with ?add_rules= in the HTTPS module source:
module "dynamodb_table" {
source = "https://soc2.compliance.tf/terraform-aws-modules/dynamodb-table/aws?version=x.y.z&add_rules=lifecycle_ignore_autoscaling_changes"
}On your organization's host, an org admin adds the rule to the Baseline, which reaches every module served from that host, or to a named ruleset that a module selects with ?ruleset=:
module "dynamodb_table" {
source = "https://bobthecorp.compliance.tf/terraform-aws-modules/dynamodb-table/aws?version=x.y.z&ruleset=<ruleset-name>"
}Replace x.y.z with the release you use and bobthecorp with your organization's alias. Which parameters each host accepts, and which it refuses with a 400, is on Rulesets in the console.
How to check it worked
Read compliancetf-manifest.json in the module you received. Its entry for this rule carries an outcome: enforced means the change was made, not_applicable means nothing matched - no resource of a targeted type, or the module already carried the identical change. Do not infer enforcement from a successful terraform init; a rule that changes nothing also inits cleanly.
Known limits
- Only affects
aws_dynamodb_table. Does not coveraws_dynamodb_global_tableor other DynamoDB resources. - Does not ignore changes to other auto-scaled attributes like GSI capacity.
- Only
.tfand.tofufiles are read. Modules written in JSON syntax (.tf.json,.tofu.json) are left untouched. - Only the module's own directory and its first-level
modules/*submodules are processed. Modules that this module calls by source URL are separate downloads and are handled on their own request. - Works with Terraform 1.x and OpenTofu 1.6 and later. The rule reads ordinary HCL, and anything it changes stays ordinary HCL.
Failure modes
| Scenario | Result |
|---|---|
| Applied to a PAY_PER_REQUEST table | The lifecycle block is still added, and the configuration stays valid. On-demand tables set no provisioned capacity, so there is nothing for the rule to suppress. |
| You switch from PROVISIONED to PAY_PER_REQUEST | The ignore_changes block has no effect on PAY_PER_REQUEST tables. No action needed. |
Related
- DynamoDB table workarounds
- Ignore tag changes
- Ignore AMI changes
- Rulesets in the console - where an org admin adds this rule to the Baseline or a ruleset
- Rule catalog - every rule, with what each one changes