Skip to main content
This lesson demonstrates Terraform’s lifecycle meta-argument — specifically ignore_changes — and how it lets you allow out-of-band updates (for example, manual tag edits in the AWS Console) without Terraform attempting to revert them. You’ll learn the minimal Terraform configuration used for the demo, how Terraform detects drift, and how adding ignore_changes changes Terraform’s behavior.
This demo uses AWS S3 resources. You should have the AWS provider configured and credentials available (for example via AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY or an AWS profile). See the Terraform docs for provider setup: https://developer.hashicorp.com/terraform/providers/aws

Resources in main.tf

The example main.tf below creates an S3 bucket plus ownership controls and an ACL. This is intentionally minimal so you can focus on lifecycle behavior.
Apply the configuration to create the bucket and supporting resources:
When prompted, respond yes. The apply will create the resources and produce output similar to:
You can confirm the bucket exists in the AWS Console:
A screenshot of the AWS S3 Buckets console showing the "General purpose buckets" view with a search for "bryans" and one result: "bryans-example-bucket-for-terraform" in the US East (N. Virginia) region.

Scenario: Out-of-band tag change

If you open the bucket in the AWS Console under Properties, you’ll see the tags created by Terraform:
  • Environment = production
  • CreatedBy = terraform
Now imagine a user manually edits the bucket tags in the AWS Console and changes Environment from production to testing. This is an out-of-band change (i.e., not made through Terraform). To see how Terraform reacts, run a refresh/plan:
Terraform refreshes state and detects differences. Example plan output showing a tag difference:
Because the configuration still sets Environment = production, Terraform plans to revert the manual change back to production.

Allowing out-of-band edits with lifecycle.ignore_changes

If you want to permit manual updates to specific attributes (for example, user-modified tags in the console) and prevent Terraform from reverting them, add a lifecycle block with ignore_changes to the resource. Update the aws_s3_bucket resource like this:
This instructs Terraform to ignore differences to the tags attribute when refreshing state and planning changes. Run terraform plan again:
After the refresh, Terraform reports no changes required:
Even though the AWS Console may still display Environment: testing, Terraform will not attempt to revert it because ignore_changes tells Terraform to stop reconciling the tags attribute:
A screenshot of an AWS S3 bucket settings page showing "Bucket Versioning" as disabled, tags (Environment: testing, CreatedBy: terraform), and default encryption details. It’s the AWS Management Console view for a specific S3 bucket.
Use ignore_changes sparingly. Ignoring changes causes Terraform to stop reconciling that attribute, which can lead to drift between your configuration and real infrastructure. Prefer allowing Terraform to manage attributes unless you have a clear operational need for out-of-band edits.

When to use ignore_changes

Summary

  • By default, Terraform detects drift between configuration and real infrastructure and will plan to reconcile differences.
  • The lifecycle meta-argument with ignore_changes allows you to instruct Terraform to ignore specific attribute changes (for example, tags) so out-of-band updates are not reverted.
  • Use ignore_changes intentionally, document why certain attributes are ignored, and minimize its scope to avoid unexpected drift.
Further reading and references: That concludes this lesson on using the lifecycle meta-argument to manage resource behavior.

Watch Video

Practice Lab