How to Handle Terraform Drift in a Large AWS Environment?
Asked by
3D_bezier
I've recently taken over a large AWS setup where Terraform is heavily utilized. The problem is, there have been manual changes and CI/CD pipelines continually making updates that aren't tracked in Terraform, leading to significant drift in the infrastructure. I'm looking for effective strategies to address and resolve this Terraform drift, especially on a large scale. Any advice would be greatly appreciated!
Answers
Have you checked out driftctl by Trivy? It doesnโt capture all resources, but it's a solid starting point. Also, if your Terraform resources arenโt tagged, consider adding a global tag to help manage whatโs out there better.
Reply to this answer
Weโve been using Spacelift for drift detection. Itโs a pretty handy tool! Just remember to only allow read access to the resources so you can reduce drift risks.
Reply to this answer
One quick way to prevent further drift is to restrict user access to the AWS console and control plane APIs. This will help keep things in check moving forward. But first, youโll need to address the existing drift!
3D_bezier: Thatโs a great point! I just need to know the best approach to actually fix the drift thatโs already there.
Reply to this answer
Add your answer
Answers are reviewed before publication.
3D_bezier: Thanks for the tip! I'll definitely look into that.