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.…