Integrating Terratest with Terraform and Terragrunt: Best Practices?
Asked by
CuriousKitten2023
I'm working on integrating Terratest into a fairly large Terraform repository that's orchestrated using Terragrunt for our AWS resources. The organization has fully adopted Terragrunt and Terraform for deployment. I'm looking for advice on how to effectively use Terratest for integration testing of Terraform modules that are managed through Terragrunt. My searches for best practices or insights have come up pretty empty, and I've noticed a lack of discussion on the implications of combining Terraform, Terragrunt, and Terratest. If anyone has experience with this setup, I'd love to hear your lessons learned, whether they're positive or negative. Thanks for your help!
Answers
From a previous team experience, we relied on Terratest for shared Terraform modules since theyโre used frequently. I set up a nightly pipeline for testing to catch any issues early, which was super effective. Just remember to clean up resources if tests fail! I even flagged bugs with Azure before they were acknowledged by Microsoft, thanks to my tests! Definitely recommend using Terratest for your modules.
Reply to this answer
Hey! As someone involved with Terragrunt and Terratest, I completely agree that we need better documentation on integrating the two. You can reference the integration guide in the documentation, and weโre working to make it easier to find. Iโd also suggest checking out our example catalog for reusable infrastructure patterns that are designed for testing. Itโs also a good idea to join our Discord community for real-time support from fellow users!
Reply to this answer
You might want to check out the official documentation on HashiCorpโs developer site before jumping into Terratest. Itโs always best to start with native tools and expand as necessary.
CodeNinja90: Totally agree, starting with what's built-in can save headaches later on.
Reply to this answer
Add your answer
Answers are reviewed before publication.
SQLGuru11: Yes, same hereโTerratest is invaluable for module testing. Never used it for infra repos, but for apps, it's great!