Skip to content

Commit

Permalink
Update terraform plan to support multi-region (#87)
Browse files Browse the repository at this point in the history
1. Updated Terraform plan workflows to run validation for multi-region
files.
---------

Co-authored-by: Sumanth Reddy Chinna Pullaiah <[email protected]>
  • Loading branch information
sumanthreddy29 and sumanthreddy29 authored Mar 5, 2024
1 parent 14ad01d commit cbcfaa0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/terraform-plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
- name: Setup test matrix scenarios
id: setup-matrix-scenarios
run: |
matrix=$(find $GITHUB_WORKSPACE/scenarios/ -name "azure.json" -o -name "aws.json" | awk -F'/' '{gsub(".json", "", $11); print "{\"cloud\": \"" $11 "\", \"scenario_type\": \"" $8 "\", \"scenario_name\": \"" $9 "\"},"}' | sort | uniq | sed 's/,$/,/')
matrix="${matrix//$'\n'/''}"
echo "matrix_combinations={\"include\": [${matrix%?}]}" >> "$GITHUB_OUTPUT"
matrix=$(find $GITHUB_WORKSPACE/scenarios/ -name "*.json" | awk -F'/' '{split($11, file_name, "."); split(file_name[1], cloud_region, "-");region= (length(cloud_region) > 1) ? substr($11, index($11, "-") + 1) : ""; cloud=cloud_region[1]; gsub(".json", "", region); print "{\"cloud\": \"" cloud "\", \"file_name\": \"" file_name[1] "\", " (region != "" ? "\"region\": \"" region "\", " : "") "\"scenario_type\": \"" $8 "\", \"scenario_name\": \"" $9 "\"},"}' | sort | uniq | sed 's/,$/,/')
matrix="${matrix//$'\n'/''}"
echo "matrix_combinations={\"include\": [${matrix%?}]}" >> "$GITHUB_OUTPUT"
outputs:
matrix-combinations: ${{ steps.setup-matrix-scenarios.outputs.matrix_combinations }}

Expand All @@ -30,7 +30,7 @@ jobs:
max-parallel: 3
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix-combinations) }}
runs-on: ubuntu-latest
name: ${{ matrix.cloud }}-${{ matrix.scenario_type }}-${{ matrix.scenario_name }}
name: ${{ matrix.cloud }}-${{ matrix.scenario_type }}-${{ matrix.scenario_name }} ${{ matrix.region }}

steps:
- name: Checkout Repository
Expand All @@ -39,8 +39,8 @@ jobs:
- name: Get job id and set env
run: |
echo "RUN_ID=123456789" >> "$GITHUB_ENV"
echo "TERRAFORM_INPUT_FILE=$GITHUB_WORKSPACE/scenarios/${{ matrix.scenario_type }}/${{ matrix.scenario_name }}/terraform-inputs/${{ matrix.cloud }}.tfvars" >> "$GITHUB_ENV"
echo "TERRAFORM_TEST_INPUT_FILE=$GITHUB_WORKSPACE/scenarios/${{ matrix.scenario_type }}/${{ matrix.scenario_name }}/terraform-test-inputs/${{ matrix.cloud }}.json" >> "$GITHUB_ENV"
echo "TERRAFORM_INPUT_FILE=$GITHUB_WORKSPACE/scenarios/${{ matrix.scenario_type }}/${{ matrix.scenario_name }}/terraform-inputs/${{ matrix.file_name }}.tfvars" >> "$GITHUB_ENV"
echo "TERRAFORM_TEST_INPUT_FILE=$GITHUB_WORKSPACE/scenarios/${{ matrix.scenario_type }}/${{ matrix.scenario_name }}/terraform-test-inputs/${{ matrix.file_name }}.json" >> "$GITHUB_ENV"
echo "USER_DATA_PATH=$GITHUB_WORKSPACE/scenarios/${{ matrix.scenario_type }}/${{ matrix.scenario_name }}/bash-scripts" >> "$GITHUB_ENV"
echo "TERRAFORM_MODULES_DIR=modules/terraform/${{ matrix.cloud }}" >> "$GITHUB_ENV"
ssh_key_path=$GITHUB_WORKSPACE/modules/terraform/${{ matrix.cloud }}/private_key.pem
Expand Down

0 comments on commit cbcfaa0

Please sign in to comment.