99 partition :
1010 required : true
1111 type : string
12+ arn_partition :
13+ required : true
14+ type : string
1215 regions :
1316 required : true
1417 type : string
@@ -30,12 +33,12 @@ jobs:
3033 region : ${{ fromJson(inputs.regions) }}
3134 steps :
3235 - name : Download Zip
33- uses : actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53
36+ uses : actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
3437 with :
3538 name : AWSLambdaPowertoolsTypeScriptV2.zip
3639
3740 - name : Download Metadata
38- uses : actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53
41+ uses : actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
3942 with :
4043 name : AWSLambdaPowertoolsTypeScriptV2.json
4144
@@ -45,10 +48,11 @@ jobs:
4548 test "$(openssl dgst -sha256 -binary AWSLambdaPowertoolsTypeScriptV2.zip | openssl enc -base64)" == "$SHA" && echo "SHA OK: ${SHA}" || exit 1
4649
4750 - id : transform
48- run : echo "CONVERTED_REGION=$(echo '${{ matrix.region }}' | tr 'a-z\-' 'A-Z_')" >> "$GITHUB_OUTPUT"
51+ run : |
52+ echo 'CONVERTED_REGION=${{ matrix.region }}' | tr 'a-z\-' 'A-Z_' >> "$GITHUB_OUTPUT"
4953
5054 - name : Configure AWS Credentials
51- uses : aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708
55+ uses : aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708 # v5.1.1
5256 with :
5357 role-to-assume : ${{ secrets[format('IAM_ROLE_{0}', steps.transform.outputs.CONVERTED_REGION)] }}
5458 aws-region : ${{ matrix.region }}
@@ -59,12 +63,13 @@ jobs:
5963 id : create-layer
6064 run : |
6165 set -euo pipefail
62- jq '{"LayerName": "AWSLambdaPowertoolsTypeScriptV2", "Description": .Description, "CompatibleRuntimes": .CompatibleRuntimes, "LicenseInfo": .LicenseInfo}' AWSLambdaPowertoolsTypeScriptV2.json > input.json
66+ cat AWSLambdaPowertoolsTypeScriptV2.json | jq '{"LayerName": "AWSLambdaPowertoolsTypeScriptV2", "Description": .Description, "CompatibleRuntimes": .CompatibleRuntimes, "LicenseInfo": .LicenseInfo}' > input.json
6367
6468 LAYER_VERSION=$(aws --region "${{ matrix.region }}" lambda publish-layer-version \
6569 --zip-file fileb://./AWSLambdaPowertoolsTypeScriptV2.zip \
6670 --cli-input-json file://./input.json \
67- --query 'Version' --output text)
71+ --query 'Version' \
72+ --output text)
6873
6974 echo "LAYER_VERSION=$LAYER_VERSION" >> "$GITHUB_OUTPUT"
7075
@@ -75,40 +80,42 @@ jobs:
7580 --principal '*' \
7681 --version-number "$LAYER_VERSION"
7782
83+ # This step retrieves the newly deployed layer metadata and compares it against the original source layer:
84+ # 1. SHA256 hash verification - ensures the layer content is identical to the source
85+ # 2. Description validation - confirms the version number in the description matches the source
86+ # 3. Layer Version number verification - validates that the layer version numbers match between source and target
87+ # 4. Tabular comparison output - displays side-by-side comparison of key layer properties
7888 - name : Verify Layer
7989 env :
8090 LAYER_VERSION : ${{ steps.create-layer.outputs.LAYER_VERSION }}
8191 ENVIRONMENT : ${{ inputs.environment }}
82- PARTITION : ${{ inputs.partition }}
92+ PARTITION : ${{ inputs.arn_partition }}
8393 run : |
8494 set -euo pipefail
85- layer_output="AWSLambdaPowertoolsTypeScriptV2-${{ matrix.region }}.json"
86-
87- aws --region "${{ matrix.region }}" lambda get-layer-version-by-arn \
88- --arn "arn:${PARTITION}:lambda:${{ matrix.region }}:${{ secrets[format('AWS_ACCOUNT_{0}', steps.transform.outputs.CONVERTED_REGION)] }}:layer:AWSLambdaPowertoolsTypeScriptV2:${LAYER_VERSION}" \
89- > "$layer_output"
95+ export layer_output="AWSLambdaPowertoolsTypeScriptV2-${{ matrix.region }}.json"
96+ # Dynamic secret access is safe here - secrets are scoped per environment
97+ aws --region "${{ matrix.region }}" lambda get-layer-version-by-arn --arn "arn:${PARTITION}:lambda:${{ matrix.region }}:${{ secrets[format('AWS_ACCOUNT_{0}', steps.transform.outputs.CONVERTED_REGION)] }}:layer:AWSLambdaPowertoolsTypeScriptV2:${LAYER_VERSION}" > "$layer_output"
9098
9199 REMOTE_SHA=$(jq -r '.Content.CodeSha256' "$layer_output")
92100 LOCAL_SHA=$(jq -r '.Content.CodeSha256' AWSLambdaPowertoolsTypeScriptV2.json)
93101 test "$REMOTE_SHA" == "$LOCAL_SHA" && echo "SHA OK: ${LOCAL_SHA}" || exit 1
94102
95103 REMOTE_DESCRIPTION=$(jq -r '.Description' "$layer_output")
96104 LOCAL_DESCRIPTION=$(jq -r '.Description' AWSLambdaPowertoolsTypeScriptV2.json)
97- test "$REMOTE_DESCRIPTION" == "$LOCAL_DESCRIPTION" && echo "Version number OK: ${LOCAL_DESCRIPTION}" || exit 1
105+ test "$REMOTE_DESCRIPTION" == "$LOCAL_DESCRIPTION" && echo "Description OK: ${LOCAL_DESCRIPTION}" || exit 1
98106
99107 if [ "$ENVIRONMENT" == "Prod" ]; then
100108 REMOTE_LAYER_VERSION=$(jq -r '.LayerVersionArn' "$layer_output" | sed 's/.*://')
101109 LOCAL_LAYER_VERSION=$(jq -r '.LayerVersionArn' AWSLambdaPowertoolsTypeScriptV2.json | sed 's/.*://')
102110 test "$REMOTE_LAYER_VERSION" == "$LOCAL_LAYER_VERSION" && echo "Layer Version number OK: ${LOCAL_LAYER_VERSION}" || exit 1
103111 fi
104112
105- jq -s -r '["Layer Arn", "Runtimes", "Version", "Description", "SHA256"], ([.[0], .[1]] | .[] | [.LayerArn, (.CompatibleRuntimes | join("/")), .Version, .Description, .Content.CodeSha256]) |@tsv' \
106- AWSLambdaPowertoolsTypeScriptV2.json "$layer_output" | column -t -s $'\t'
113+ 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'
107114
108- - name : Store Metadata
109- uses : actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
115+ - name : Store Metadata - ${{ matrix.region }}
116+ uses : actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
110117 with :
111- name : AWSLambdaPowertoolsTypeScriptV2-${{ inputs.environment }}-${{ matrix.region }}.json
118+ name : AWSLambdaPowertoolsTypeScriptV2-${{ matrix.region }}.json
112119 path : AWSLambdaPowertoolsTypeScriptV2-${{ matrix.region }}.json
113120 retention-days : 1
114121 if-no-files-found : error
0 commit comments