We have an ECS service that is being recreated and were getting issues that a Security Group already existed. The state-file was correctly tracking that security group but it would only ever try to create (and not destroy) when it came time to apply.
In the plan, the security group was being replaced explicitly because of the VPC. The plan changed between the following two iterations of the Data Source block for the VPC.
data "aws_vpc" "target_vpc" {
tags = {
Zone = var.zone
}
}
data "aws_vpc" "target_vpc" {
id = "vpc-123"
}
There was only once VPC with the “Zone” tag set so it should only identify one. I added count = 1
as well but that produced the same plan as the Tag lookup by itself. Lookup by Id did not force replacement of the consuming security group. Ideas as to the reason for this behavior?