An example Terraform project demonstrating continuous deployment pipeline using GitHub Actions' environment function.
- Deployment workflow runs every time
main
branch is updated. It first runsterraform plan
and require a manual approval.terraform apply
will be executed when the job is approved. - Preview workflow runs
terraform plan
for each pull request and comment the plan result. The comment is updated when new commits are added to the pull request.
- Create two environments
production
andproduction-readonly
.- Set required reviewers to
production
environment. - Associate credentials which has sufficient permissions to run
terraform plan
toproduction-readonly
environment. - Associate credentials which has sufficient permissions to run
terraform apply
toproduction
environment.
- Set required reviewers to
- Terraform project is assumed to have a non-local backend to host state files.