Skip to content

Terraform test GH actions #96

Terraform test GH actions

Terraform test GH actions #96

Workflow file for this run

name: "Terraform test GH actions"
on:
push:
branches:
- main
paths:
- 'terraform/**'
pull_request:
branches:
- main
paths:
- 'terraform/**'
workflow_dispatch: # Manually trigger the workflow
env:
TF_LOG: INFO
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE }}
jobs:
terraform:
name: "Terraform Infrastructure Change Management"
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ./terraform
steps:
- name: Checkout the repository to the runner
uses: actions/checkout@v2
- name: Setup Terraform with specified version on the runner
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.3.0
- name: Terraform init
id: init
run: terraform init -backend-config="bucket=${BUCKET_TF_STATE}"
- name: Terraform format
id: fmt
run: terraform fmt -check
- name: Terraform validate
id: validate
run: terraform validate
- name: Terraform plan
id: plan
run: terraform plan -no-color -input=false
- name: Terraform apply
id: apply
run: terraform apply --auto-approve
- name: Terraform destroy
id: destroy
run: terraform destroy --auto-approve