I am trying to use Terraform to manage the infrastructure for an EC2 app that uses AWS CodeDeploy Blue/Green deployments to deploy, but I am having issues with deployments putting my terraform state out-of-date. I know from the terraform resource documentation that I need to set
DISCOVER_EXISTING. However, that alone isn’t solving my problem.
The problem is that if I set up ASGs
B, create a deployment group with ASG
A as my blue fleet, and deploy to ASG
B as my green fleet, the
aws_codedeploy_deployment_group is modified to be associated with ASG
B as the new blue fleet. Then, if I try to
terraform apply, the resulting plan tries to reassociate my deployment group with ASG
A, since that’s what the configuration says.
Has anyone managed to get an EC2 app deploying with AWS CodeDeploy Blue/Green deployments which doesn’t lead Terraform to try to make extra changes? If so, how?