Skip to content

Terraform Plan

Terraform Plan #40

name: 'Terraform Plan'
on:
workflow_dispatch:
inputs:
workspace:
description: 'Terraform Workspace which should map to GitHub Environment'
required: true
default: 'Dev'
type: choice
options:
- Dev
- Test
- Pre-Prod
- Prod
- Load-Test
permissions:
contents: read
jobs:
terraform-plan:
name: 'Terraform Plan'
runs-on: ubuntu-latest
environment: ${{inputs.workspace}}
env:
ARM_CLIENT_ID: ${{secrets.TF_ARM_CLIENT_ID}}
ARM_CLIENT_SECRET: ${{secrets.TF_ARM_CLIENT_SECRET}}
ARM_SUBSCRIPTION_ID: ${{secrets.TF_ARM_SUBSCRIPTION_ID}}
ARM_TENANT_ID: ${{secrets.TF_ARM_TENANT_ID}}
TF_VAR_tenant_id: ${{secrets.TF_ARM_TENANT_ID}}
TF_VAR_cpd_client_id: ${{secrets.TF_VAR_CPD_CLIENT_ID}}
TF_VAR_cpd_client_secret: ${{secrets.TF_VAR_CPD_CLIENT_SECRET}}
TF_VAR_cpd_keyvaultendpoint: ${{secrets.TF_VAR_CPD_KEYVAULTENDPOINT}}
TF_VAR_cpd_googleanalyticstag: ${{secrets.TF_VAR_CPD_GOOGLEANALYTICSTAG}}
TF_VAR_cpd_space_id: ${{secrets.TF_VAR_CPD_SPACE_ID}}
TF_VAR_cpd_preview_key: ${{secrets.TF_VAR_CPD_PREVIEW_KEY}}
TF_VAR_cpd_delivery_key: ${{secrets.TF_VAR_CPD_DELIVERY_KEY}}
TF_VAR_cpd_clarity: ${{secrets.TF_VAR_CPD_CLARITY}}
TF_VAR_cpd_image_tag: ${{vars.TF_VAR_CPD_IMAGE_TAG}}
TF_VAR_cpd_feature_polling_interval: ${{vars.TF_VAR_CPD_FEATURE_POLLING_INTERVAL}}
TF_WORKSPACE: ${{inputs.workspace}}
defaults:
run:
shell: bash
steps:
# Checkout code
- name: Checkout
uses: actions/checkout@v3
# Install the latest version of Terraform CLI
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
run: terraform -chdir=Terraform init -backend-config=${TF_WORKSPACE}-backend.conf
# Checks that all Terraform configuration files adhere to a canonical format
- name: Terraform Format
run: terraform -chdir=Terraform fmt -check -recursive
# Validate Terraform before planning
- name: Terraform Validate
run: terraform -chdir=Terraform validate
# Generates an execution plan for Terraform
- name: Terraform Plan
run: terraform -chdir=Terraform plan -input=false