Menu

1 / 2

Terraform ignore_changes: When to Use It, and When It Hides Drift

DEV Community: terraform·akshay kilam·3 days ago
#60VIC4tV
Long article (1117 words) — no AI summary yet.
Reading 0:00
15s threshold

ignore_changes tells Terraform to stop correcting certain attributes of a resource. It is the right tool when something else legitimately owns a value, such as an autoscaler or a deploy pipeline. It is the wrong tool when someone changed a resource in the console and the next plan wanted to put it back. In that case it hides drift instead of fixing it.

This guide covers the syntax, the cases where it belongs, ignoring tags, the common errors, and how to keep it from becoming a place where drift goes unnoticed.

How ignore_changes works

ignore_changes lives in a resource's lifecycle block and takes a list of attribute names:

resource "aws_ecs_service" "api" { name = "api" cluster = aws_ecs_cluster . main . id task_definition = aws_ecs_task_definition . api . arn desired_count = 2

lifecycle { ignore_changes = [ desired_count ] } }

Enter fullscreen mode

Exit fullscreen mode

Terraform uses desired_count = 2 when it creates the service.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.