|
15 | 15 | # 1. After the `make-release` workflow finishes and the PR for the documentation update gets created, trigger this workflow manually via `workflow_dispatch` with environment, version, and partition inputs for each Gamma and Prod environment in the China and GovCloud partitions
|
16 | 16 | # 2. Monitor deployment progress and verify successful layer publication across all target regions
|
17 | 17 | # 3. Once this workflow is completed, the PR for the documentation update can me merged
|
| 18 | +# |
| 19 | +# CodeQL Security Note: |
| 20 | +# This workflow uses dynamic secret access via secrets[format(...)] which triggers |
| 21 | +# an "Excessive Secrets Exposure" alert. However, this is safe because: |
| 22 | +# - Secrets are scoped per environment (China/GovCloud Gamma/Prod) |
| 23 | +# - Each job only accesses secrets for its specific partition and region |
| 24 | +# - No global secrets array containing mixed credentials (API keys, PEM files, etc.) |
| 25 | +# - The secrets object is already minimally scoped to the environment being used |
18 | 26 |
|
19 | 27 | on:
|
20 | 28 | workflow_dispatch:
|
@@ -142,6 +150,7 @@ jobs:
|
142 | 150 | - name: Configure AWS Credentials
|
143 | 151 | uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1
|
144 | 152 | with:
|
| 153 | + # Dynamic secret access is safe here - secrets are scoped per environment |
145 | 154 | role-to-assume: ${{ secrets[format('IAM_ROLE_{0}', steps.transform.outputs.CONVERTED_REGION)] }}
|
146 | 155 | aws-region: ${{ matrix.region}}
|
147 | 156 | mask-aws-account-id: true
|
@@ -175,16 +184,19 @@ jobs:
|
175 | 184 | LAYER_VERSION: ${{ steps.create-layer.outputs.LAYER_VERSION }}
|
176 | 185 | run: |
|
177 | 186 | export layer_output='AWSLambdaPowertoolsTypeScriptV2-${{matrix.region}}.json'
|
| 187 | + # Dynamic secret access is safe here - secrets are scoped per environment |
178 | 188 | aws --region ${{ matrix.region}} lambda get-layer-version-by-arn --arn 'arn:${{ needs.setup.outputs.partition }}:lambda:${{ matrix.region}}:${{ secrets[format('AWS_ACCOUNT_{0}', steps.transform.outputs.CONVERTED_REGION)] }}:layer:AWSLambdaPowertoolsTypeScriptV2:${{ env.LAYER_VERSION }}' > $layer_output
|
179 | 189 | REMOTE_SHA=$(jq -r '.Content.CodeSha256' $layer_output)
|
180 | 190 | LOCAL_SHA=$(jq -r '.Content.CodeSha256' AWSLambdaPowertoolsTypeScriptV2.json)
|
181 | 191 | test "$REMOTE_SHA" == "$LOCAL_SHA" && echo "SHA OK: ${LOCAL_SHA}" || exit 1
|
182 | 192 | REMOTE_DESCRIPTION=$(jq -r '.Description' $layer_output)
|
183 | 193 | LOCAL_DESCRIPTION=$(jq -r '.Description' AWSLambdaPowertoolsTypeScriptV2.json)
|
184 | 194 | test "$REMOTE_DESCRIPTION" == "$LOCAL_DESCRIPTION" && echo "Version number OK: ${LOCAL_DESCRIPTION}" || exit 1
|
185 |
| - REMOTE_LAYER_VERSION=$(jq -r '.LayerVersionArn' $layer_output | sed 's/.*://') |
186 |
| - LOCAL_LAYER_VERSION=$(jq -r '.LayerVersionArn' AWSLambdaPowertoolsTypeScriptV2.json | sed 's/.*://') |
187 |
| - test "$REMOTE_LAYER_VERSION" == "$LOCAL_LAYER_VERSION" && echo "Layer Version number OK: ${LOCAL_LAYER_VERSION}" || exit 1 |
| 195 | + if [ "${{ inputs.environment }}" == "Prod" ]; then |
| 196 | + REMOTE_LAYER_VERSION=$(jq -r '.LayerVersionArn' $layer_output | sed 's/.*://') |
| 197 | + LOCAL_LAYER_VERSION=$(jq -r '.LayerVersionArn' AWSLambdaPowertoolsTypeScriptV2.json | sed 's/.*://') |
| 198 | + test "$REMOTE_LAYER_VERSION" == "$LOCAL_LAYER_VERSION" && echo "Layer Version number OK: ${LOCAL_LAYER_VERSION}" || exit 1 |
| 199 | + fi |
188 | 200 | jq -s -r '["Layer Arn", "Runtimes", "Version", "Description", "SHA256"], ([.[0], .[1]] | .[] | [.LayerArn, (.CompatibleRuntimes | join("/")), .Version, .Description, .Content.CodeSha256]) |@tsv' AWSLambdaPowertoolsTypeScriptV2.json $layer_output | column -t -s $'\t'
|
189 | 201 |
|
190 | 202 | - name: Store Metadata - ${{ matrix.region }}
|
|
0 commit comments