Skip to content

Task 1: AWS Account Configuration #4

Task 1: AWS Account Configuration

Task 1: AWS Account Configuration #4

Workflow file for this run

name: Terraform Workflow
on:
pull_request:
branches:
- main
jobs:
terraform-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.9.6
- name: Terraform Format Check
run: terraform fmt -check
terraform-plan:
runs-on: ubuntu-latest
needs: terraform-check
permissions:
id-token: write
contents: read
steps:
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.9.6
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/GithubActionsRole
aws-region: us-east-1
- name: Terraform Init
run: terraform init
- name: Terraform Plan
run: terraform plan
terraform-apply:
runs-on: ubuntu-latest
needs: terraform-plan
permissions:
id-token: write
contents: read
if: github.ref == 'refs/heads/main'
steps:
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.9.6
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/GithubActionsRole
aws-region: us-east-1
- name: Terraform Init
run: terraform init
- name: Terraform Apply
run: terraform apply -auto-approve