11 Terraform in Automation
This chapter covers:
- Designing workflows for running Terraform at scale
- Developing a CI/CD pipeline for automating Terraform deployments
- Generating Terraform configuration code
- Toggling dynamic blocks with a conditional expression
If you are struggling with how to run Terraform at scale, rest easy friend, because this chapter is for you. Until now, I have assumed you are deploying Terraform from your local machine. This is a reasonable assumption for individuals and even small teams (as long as you are using a remote state backend). Large teams and organizations with many individual contributors, on the other hand, would benefit from running Terraform in automation.
As you may recall from chapter 6, HashiCorp already has two products designed for running Terraform in automation: Terraform Cloud and Terraform Enterprise. They are basically the same product; Terraform Cloud is just the managed SaaS offering of Terraform Enterprise. In this chapter we will develop a CI/CD pipeline for deploying Terraform workspaces in automation, modeled after the design of Terraform Enterprise. The stages of the CI/CD pipeline are shown in figure 11.1.