Terraform v0.11.7
data "aws_ami" "testAmi" {
...
}
resource "aws_launch_configuration" "testLC" {
image_id = "${data.aws_ami.testAmi.id}"
instance_type = "m4.xlarge"
name_prefix = "testLC-"
user_data = "test1"
lifecycle {
create_before_destroy = true,
prevent_destroy = false
}
}
resource "aws_autoscaling_group" "testASG" {
max_size = 1
min_size = 1
health_check_grace_period = 600
health_check_type = "ELB"
launch_configuration = "${aws_launch_configuration.testLC.name}"
name = "${aws_launch_configuration.testLC.name}-asg"
vpc_zone_identifier = [ "test-vpc-zone" ]
lifecycle {
ignore_changes = [ "health_check_grace_period" ]
}
}
After applying the above, I would expect that when I make a change that forces a new resources for the aws_launch_configuration (e.g changing the user_data), the aws_autoscaling_group would have its launch_configuration updated and a new resource forced since its name depends on the aws_launch_configuration. Note that this works fine if the ASG's ignore_changes is empty.
Changing the user_data for the aws_launch_configuration forces a new resource for the launch configuration, but does NOT cause an update of the aws_autoscaling_group.
terraform applyterraform plan, note that testLC is updated but testASG is notterraform plan, note that now testASG is updatedterraform plan, again note that testASG is updatedVery similar in my case. A few notes: any changes in LC which will require LC recreation could be used, not only changes in user_data. In my case, desired_count was ignored in ASG and led to the same results. Even when desired_count attribute was absent from ASG configuration
I don't know if this is relevant, but when my team updated the AWS provider from 1.60 to the latest 2.x release, we saw this manifest (exactly the same case as @dvishniakov where we ignore the desired_capacity attribute)
If anyone has an idea where I should start looking so that we can fix this I'd be glad to work on the problem... but short of any advice I'd probably not make any meaningful progress.
I see this here when running TF_LOG=debug:
2019/09/03 18:21:01 [DEBUG] Removing 'id' diff and setting Destroy to false because after ignore_changes, this diff no longer requires replacement
2019/09/03 18:21:01 [DEBUG] [EvalIgnoreChanges] aws_autoscaling_group.asg - Ignoring diff attribute: name_prefix
And that's defined here https://github.com/hashicorp/terraform/blob/v0.11/terraform/eval_diff.go#L281. For some reason despite name_prefix changing Terraform decides that it does not need to recreate the resource. I'm still not sure how to fix this, though.
Based on testing (and communicating with @lowjoel), this behavior does not occur with Terraform 0.12.x. Just FYI for anyone watching this issue.
Most helpful comment
Based on testing (and communicating with @lowjoel), this behavior does not occur with Terraform 0.12.x. Just FYI for anyone watching this issue.