I'm using Terraform with AWS. Currently in my setup, I have an Auto Scaling Group used in conjunction with Code Deploy. When I deploy into Code Deploy, it copies the initial ASG, and deletes it. The issue is that when I run 'terraform plan/apply', it wants to recreate the original ASG, and repoint my Code Deploy group.
Obviously, this breaks things. Is there a way I can tell Terraform to leave my ASG/CodeDeploy stuff alone? I would comment out the modules containing these items, but I'm scared Terraform will look at the current state, see that some components are missing, and try to delete them.
Any help is greatly appreciated.
In the hopes this gets marked as answered, the comment by @mblakele is an effective solution to this issue.
The ignore_changes lifecycle rule can affect the state enforcement of a resource such that Terraform will only create the resource and destroy it if the TF config doesn't change.
This can be added to a given resource block to affect the behavior described above:
Destroying this resource may still produce an error (it doesn't exist), though that can be dealt with as a touchpoint if that happens.