Terraform plan dev by @alismx #213
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: Ad-hoc Terraform Plan | |
run-name: Terraform plan ${{ inputs.env }} by @${{ github.actor }} | |
on: | |
workflow_dispatch: | |
inputs: | |
env: | |
description: 'What to plan against' | |
required: true | |
type: choice | |
options: | |
- dev | |
- dev2 | |
- dev3 | |
- dev4 | |
- dev5 | |
- dev6 | |
- pentest | |
- test | |
- demo | |
- training | |
- stg | |
- prod | |
- all_environments | |
env: | |
ARM_CLIENT_ID: ${{ secrets.TERRAFORM_ARM_CLIENT_ID }} | |
ARM_CLIENT_SECRET: ${{ secrets.TERRAFORM_ARM_CLIENT_SECRET }} | |
ARM_SUBSCRIPTION_ID: ${{ secrets.TERRAFORM_ARM_SUBSCRIPTION_ID }} | |
ARM_TENANT_ID: ${{ secrets.TERRAFORM_ARM_TENANT_ID }} | |
OKTA_API_TOKEN: ${{ secrets.OKTA_API_TOKEN_NONPROD }} | |
jobs: | |
matrix_prep: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set_matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: set_matrix | |
run: | | |
if [[ "${{ inputs.env }}" == "all_environments" ]]; then | |
matrix=[{\"env\":\"dev\"},{\"env\":\"dev2\"},{\"env\":\"dev3\"},{\"env\":\"dev4\"},{\"env\":\"dev5\"},{\"env\":\"dev6\"},{\"env\":\"pentest\"},{\"env\":\"test\"},{\"env\":\"demo\"},{\"env\":\"training\"},{\"env\":\"stg\"},{\"env\":\"prod\"}] | |
else | |
matrix=[{\"env\":\"${{ inputs.env }}\"}] | |
fi | |
echo "matrix={\"include\":$(echo $matrix)}" >> $GITHUB_OUTPUT | |
terraform_plan: | |
needs: matrix_prep | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}} | |
defaults: | |
run: | |
working-directory: ./ops | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Use prod Okta token if required | |
if: ${{ matrix.env == 'prod' || matrix.env == 'stg' || matrix.env == 'training' }} | |
run: | | |
echo "OKTA_API_TOKEN=${{ secrets.OKTA_API_TOKEN }}" >> "$GITHUB_ENV" | |
- uses: hashicorp/[email protected] | |
with: | |
terraform_version: 1.3.3 | |
- name: Terraform Init | |
run: make init-${{ matrix.env }} | |
- name: Build ReportStream function app | |
uses: ./.github/actions/build-reportstream-functions | |
with: | |
deploy-env: ${{ matrix.env }} | |
- name: Terraform plan | |
run: make plan-${{ matrix.env }} | |
- name: Terraform key rotation prod plan | |
if: ${{ matrix.env == 'prod' || matrix.env == 'stg' || matrix.env == 'training' }} | |
uses: ./.github/actions/key-replace | |
with: | |
azure_creds: ${{ secrets.AZURE_CREDENTIALS }} | |
deploy_env: ${{ matrix.env }} | |
terraform_arm_client_id: ${{ secrets.TERRAFORM_ARM_CLIENT_ID }} | |
terraform_arm_client_secret: ${{ secrets.TERRAFORM_ARM_CLIENT_SECRET }} | |
terraform_arm_subscription_id: ${{ secrets.TERRAFORM_ARM_SUBSCRIPTION_ID }} | |
terraform_arm_tenant_id: ${{ secrets.TERRAFORM_ARM_TENANT_ID }} | |
okta_api_token: ${{ secrets.OKTA_API_TOKEN }} | |
- name: Terraform key rotation plan | |
if: ${{ matrix.env != 'prod' && matrix.env != 'stg' && matrix.env != 'training' }} | |
uses: ./.github/actions/key-replace | |
with: | |
azure_creds: ${{ secrets.AZURE_CREDENTIALS }} | |
deploy_env: ${{ matrix.env }} | |
terraform_arm_client_id: ${{ secrets.TERRAFORM_ARM_CLIENT_ID }} | |
terraform_arm_client_secret: ${{ secrets.TERRAFORM_ARM_CLIENT_SECRET }} | |
terraform_arm_subscription_id: ${{ secrets.TERRAFORM_ARM_SUBSCRIPTION_ID }} | |
terraform_arm_tenant_id: ${{ secrets.TERRAFORM_ARM_TENANT_ID }} | |
okta_api_token: ${{ secrets.OKTA_API_TOKEN_NONPROD }} |