From 067a54668a3de948d97ca66060ee16915c9833c9 Mon Sep 17 00:00:00 2001 From: MariusB-DevOps Date: Mon, 9 Dec 2024 14:55:14 +0000 Subject: [PATCH] Modified user mapping reding mode --- .github/workflows/terraform-apply.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/terraform-apply.yml b/.github/workflows/terraform-apply.yml index fa79484..b0cbbd0 100644 --- a/.github/workflows/terraform-apply.yml +++ b/.github/workflows/terraform-apply.yml @@ -20,10 +20,10 @@ jobs: - name: List .github/workflows directory run: ls -la .github/workflows - - name: Read User Mapping + - name: Read User Mapping (Improved) id: user-mapping run: | - USER_MAPPING=$(cat .github/workflows/user-mapping.json) + USER_MAPPING=$(secrets.USER_MAPPING_JSON) # Assuming stored as a GitHub Secret USER_CREDENTIALS=$(jq -r --arg USERNAME "$GITHUB_ACTOR" '.[$USERNAME]' <<< "$USER_MAPPING") echo "::set-output name=user-mapping::${USER_CREDENTIALS}" @@ -31,12 +31,12 @@ jobs: run: echo "${{ steps.user-mapping.outputs.user-mapping }}" # Step 0.1: Set AWS credentials - - name: Set AWS Credentials + - name: Set AWS Credentials (Simplified) run: | - USER_MAPPING=$(cat .github/workflows/user-mapping.json) - USER_CREDENTIALS=$(jq -r --arg USERNAME "$GITHUB_ACTOR" '.[$USERNAME]' <<< "$USER_MAPPING") - echo "AWS_SECRET_ACCESS_KEY=$(echo "$USER_CREDENTIALS" | jq -r '.AWS_SECRET_ACCESS_KEY')" >> $GITHUB_ENV - echo "AWS_SECRET_KEY_ID=$(echo "$USER_CREDENTIALS" | jq -r '.AWS_SECRET_KEY_ID')" >> $GITHUB_ENV + USER_CREDENTIALS=$(echo "${{ steps.user-mapping.outputs.user-mapping }}" | jq -r '.AWS_SECRET_ACCESS_KEY') + echo "AWS_SECRET_ACCESS_KEY=$USER_CREDENTIALS" >> $GITHUB_ENV + USER_CREDENTIALS=$(echo "${{ steps.user-mapping.outputs.user-mapping }}" | jq -r '.AWS_SECRET_KEY_ID') + echo "AWS_SECRET_KEY_ID=$USER_CREDENTIALS" >> $GITHUB_ENV # Step 1: Configure AWS credentials - name: Configure AWS credentials