GitHub Actions for working with Terraform
Let's look at an example, assume our repo is called amazing-app:
λ amazing-app ❯ tree
.
├── README.md
├── terraform
│ ├── env
│ │ ├──dev.tf
│ │ ├──tst.tf
│ │ └──prd.tf
│ ├── backend.tf
│ ├── main.tf
│ ├── variables.tf
│ └── versions.tf
└── .github
└── workflows
├── cd.yml
└── ci.ymlname: CI
on:
pull_request:
jobs:
terraform-lint:
uses: entur/gha-terraform/.github/workflows/lint.yml@v1
terraform-plan:
uses: entur/gha-terraform/.github/workflows/plan.yml@v1name: CD
on:
pull_request:
jobs:
terraform-apply:
uses: entur/gha-terraform/.github/workflows/apply.yml@v1If you don't want to use a third party application to create an approval step before apply, you can use Github Environments, For inspiration: https://github.com/entur/thanos/blob/main/.github/workflows/cd.yml