Terraform Deploy #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| - name: Terraform Apply | |
| run: terraform apply -auto-approve tfplan | |
| - name: Output Results | |
| if: always() | |
| run: terraform output -json |