Terraform Plan Apply #6
This file contains 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 Plan Apply | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
plan: | |
environment: test | |
name: "Run Terraform Plan" | |
runs-on: ubuntu-20.04 | |
env: | |
tf-version: 1.3.9 | |
defaults: | |
run: | |
working-directory: . | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@v2 | |
- name: Setup Terraform | |
uses: hashicorp/[email protected] | |
with: | |
terraform_version: ${{ env.tf-version }} | |
terraform_wrapper: true | |
- name: configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: us-east-2 | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | |
- name: Terraform Init | |
id: init | |
run: terraform init -no-color | |
- name: Create Artifact Folder | |
shell: bash | |
run: | | |
sudo mkdir -p -m777 ${{ github.workspace }}/tfplanoutput | |
- name: Terraform Plan | |
id: plan | |
run: | | |
terraform plan -no-color -var-file=test-env.tfvars -out=${{ github.workspace }}/tfplanoutput/tf.plan | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: artifact | |
path: ${{ github.workspace }}/tfplanoutput/ | |
if-no-files-found: error | |
apply: | |
name: "Run Terraform Apply" | |
needs: plan | |
runs-on: ubuntu-20.04 | |
environment: test | |
env: | |
tf-version: 1.3.9 | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@v2 | |
- name: Setup Terraform | |
uses: hashicorp/[email protected] | |
with: | |
terraform_version: ${{ env.tf-version }} | |
terraform_wrapper: true | |
- name: configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: us-east-2 | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | |
- name: Terraform Init | |
id: init | |
run: terraform init -no-color | |
- name: Download Build Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifact | |
path: ${{ github.workspace }}/tfplanoutput | |
- name: Terraform Apply | |
id: apply | |
run: | | |
terraform apply -no-color -input=false ${{ github.workspace }}/tfplanoutput/tf.plan | |
- name: Terraform Output | |
id: output | |
run: | | |
terraform output |