The ultimate CircleCI config for Terraform pull request workflow
terraform circleci github
Terraform is an extremely powerful tool, but the out-of-the-box workflow can lead to pitfalls such as forgetting to commit and push changes to manifest and
Use this example CircleCI configuration for a rock-solid pull-request workflow for Terraform projects.
- A project contributor creates a pull request with changes to terraform manifests.
- CircleCI runs a
terraform planand posts the diff as a comment in the pull request.
- When the PR is merged to
master, CircleCI runs
terraform applyto resolve the diffs.
Add an environment variable
GITHUB_TOKEN with the personal access token of a bot user (this is used to post the comment on the PR).
You will also need to add authentication environment variables for your cloud provider (in AWS this is
Ensure your state is stored in remote storage, such as S3.
.circleci/plan-comment.tpl from the gist below to your repo.