Skip to content

Update Terraform deployment workflow #4

Update Terraform deployment workflow

Update Terraform deployment workflow #4

name: Terraform Deploy
on:
workflow_dispatch:
push:
branches: [develop]
paths:
- '**.tf'
- '**.tfvars'
- '.github/workflows/terraform-deploy.yml'
jobs:
deploy:
name: Terraform Apply
runs-on: ubuntu-latest
environment: production
permissions:
id-token: write
contents: read
env:
AWS_REGION: eu-west-1
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure AWS credentials via OIDC
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/terraform-github-actions
aws-region: eu-west-1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.5.7
- name: Terraform Init
run: terraform init -input=false
- name: Terraform Plan
id: plan
run: |
terraform plan -out=tfplan -no-color -input=false \
-var="db_password=${{ secrets.DB_PASSWORD }}"
- name: Terraform Apply
run: terraform apply -auto-approve tfplan
- name: Output Results
if: always()
run: terraform output -json