Skip to content

indent azure modules #194

indent azure modules

indent azure modules #194

name: 'Plan Sonar CLI'
on:
workflow_call:
inputs:
use_modules_from_terraform_registry:
required: true
type: boolean
explicit_ref:
required: true
type: string
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
AWS_ACCESS_KEY_ID_STAGE:
required: true
AWS_SECRET_ACCESS_KEY_STAGE:
required: true
workflow_dispatch:
inputs:
use_modules_from_terraform_registry:
type: boolean
required: false
push:
branches:
- '*'
- '!master'
- '!dev'
permissions:
contents: read
jobs:
terraform:
# name: 'Terraform'
runs-on: ubuntu-latest
environment: test
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
- name: Sonar Basic
example: ./examples/poc/sonar_basic_deployment
- name: Sonar HADR
example: ./examples/poc/sonar_hadr_deployment
- name: Sonar Single Account
example: ./examples/installation/sonar_single_account_deployment
- name: Sonar Multi Account
example: ./examples/installation/sonar_multi_account_deployment
name: '${{ matrix.name }}'
env:
TF_CLI_ARGS: "-no-color"
TF_INPUT: 0
AWS_REGION: us-west-2
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- name: Pick ref
run: |
if [ -z "${{ inputs.explicit_ref }}" ]; then
echo REF=${{ github.ref }} >> $GITHUB_ENV;
else
echo REF=${{ inputs.explicit_ref }} >> $GITHUB_ENV;
fi
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ env.REF }}
- name: Change the modules source to local
if: ${{ inputs.use_modules_from_terraform_registry == false }}
run: |
find ./examples/ -type f -exec sed -i -f sed.expr {} \;
# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ~1.5.0
- name: Configure AWS credentials - innodev
if: contains(matrix.name, 'single account') || contains(matrix.name, 'multi account')
run: |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} --profile innodev
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} --profile innodev
- name: Configure AWS credentials - innostage
if: contains(matrix.name, 'single account') || contains(matrix.name, 'multi account')
run: |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID_STAGE }} --profile innostage
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY_STAGE }} --profile innostage
- name: Get AWS credentials
run: |
aws sts get-caller-identity
- name: Create tfvars File
if: contains(matrix.name, 'Single Account') || contains(matrix.name, 'Multi Account')
run: |
if [ "${{ matrix.name }}" == "Sonar Single Account" ]; then
cat << EOF > "${{ matrix.example }}/terraform.tfvars"
${{ vars.TFVAR_PARAMETERS_SINGLE_ACCOUNT_AUTOMATION }}
EOF
elif [ "${{ matrix.name }}" == "Sonar Multi Account" ]; then
cat << EOF > "${{ matrix.example }}/terraform.tfvars"
${{ vars.TFVAR_PARAMETERS_MULTI_ACCOUNT_AUTOMATION }}
EOF
fi
- name: View The Vars
if: contains(matrix.name, 'single account') || contains(matrix.name, 'multi account')
run: cat ${{ matrix.example }}/terraform.tfvars
# 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=${{ matrix.example }} init
- name: Terraform Validate
run: terraform -chdir=${{ matrix.example }} validate
# Checks that all Terraform configuration files adhere to a canonical format
- name: Terraform Format
run: terraform fmt -check
continue-on-error: true
# Generates an execution plan for Terraform
- name: Terraform Plan
run: terraform -chdir=${{ matrix.example }} plan