HashiCorp is excited to announce the release of pipeline templates for Terraform Cloud and Terraform Enterprise. These templates come with a command line tool for prescriptively setting up and running a Terraform Cloud workflow within a CI/CD pipeline, reducing friction that can often occur in highly customized pipelines. The templates also provide prescriptive examples for other CI/CD platforms on how to integrate with Terraform Cloud.
This post introduces two new pipeline templates and offers some background on how these integrations work and the customer feedback that led to them.
The need for a prescriptive approach to using Terraform with CI/CD
One request we often get from Terraform Cloud users is for prescriptive guidance on how to use Terraform Cloud in their CI/CD pipelines. In addition, we know that many of our partners who offer CI/CD platforms want to provide their users with prescriptive Terraform Cloud integration workflows from their side as well. While Terraform Cloud’s VCS workflows are the initial solution we recommend, many customers have existing CI/CD tooling in place and want to integrate Terraform Cloud into their custom pipelines.
For tricky integrations, users typically embed Terraform Cloud as a job within CI/CD workflows and use the CLI workflow within a CI/CD tool to execute plans and applies. This approach is simple to implement but does not provide all the capabilities of Terraform Cloud, such as saving cloud runs and a bi-directional link back from Terraform Cloud to the code. These features are available only via API workflows, but those workflows are also more complex to set up.
Terraform Cloud APIs represent the actions that are part of a run from Terraform Cloud’s perspective, such as packaging and uploading code, starting runs, and applying changes. These common actions are automatically executed as part of the CLI or VCS workflow, so they are harder to implement without more detailed knowledge of the Terraform Cloud APIs
How the application and templates work
To reduce the friction of this integration process, we created a new CLI tool called
tfci. It’s a Go application inside a Docker container that automates Terraform Cloud runs via API and supports common Terraform Cloud operations that can be embedded into any CI tool. This allows users to onboard Terraform Cloud into more complex CI/CD pipelines.
tfci, we created a pair of initial pipeline templates that act as blueprints for integrating
tfci into CI/CD platforms:
GitHub Actions and GitLab CI are the two most common platforms for which users requested prescriptive workflows. Our intention is for third parties to participate and also add additional workflows and CI/CD platforms over time. Note that
tfci can still be used to integrate Terraform Cloud into any CI/CD platform. Pipeline templates simply make the process faster and easier. Also note that
tfci works with current versions of Terraform Enterprise since it uses the same APIs.
Final notes and next steps
HashiCorp has published
tfci on our tfc-workflows-tooling GitHub repository. The CI/CD pipeline templates are located in these two repositories:
If you want a hands-on guide for setting up
tfci-powered GitHub Actions workflows, follow our updated Automate Terraform with GitHub Actions tutorial.
In each repository you can find documentation and open pull requests or issues. If you have an idea or want to see something new, please let us know by getting in touch through these GitHub repos.
from HashiCorp Blog https://bit.ly/3Wza0lM
Post a Comment