Skip to content

Commit 0fa10e1

Browse files
committed
fixed the partition in the arn
1 parent 7d505d7 commit 0fa10e1

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

.github/workflows/layers_partitions.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# ---
33
# This workflow publishes a specific layer version in an AWS account based on the partition input.
44
#
5-
# We pull the version of the layer and store them as artifacts, the we upload them to each of the Partitioned AWS accounts.
5+
# We pull the version of the layer and store them as artifacts, then we upload them to each of the Partitioned AWS accounts.
66
#
77
# A number of safety checks are performed to ensure safety.
88
#
@@ -112,17 +112,19 @@ jobs:
112112
with:
113113
environment: Gamma
114114
partition: ${{ inputs.partition }}
115+
arn_partition: ${{ needs.setup.outputs.partition }}
115116
regions: ${{ needs.setup.outputs.regions }}
116117
aud: ${{ needs.setup.outputs.aud }}
117118
secrets: inherit
118-
# Copies the Layer to the Gamma Environment in the selected partition
119+
# Copies the Layer to the Prod Environment in the selected partition
119120
deploy-prod:
120121
name: Deploy Prod Layer
121122
needs: [setup, download, deploy-gamma]
122123
uses: ./.github/workflows/layers_partitions_deploy.yml
123124
with:
124125
environment: Prod
125126
partition: ${{ inputs.partition }}
127+
arn_partition: ${{ needs.setup.outputs.partition }}
126128
regions: ${{ needs.setup.outputs.regions }}
127129
aud: ${{ needs.setup.outputs.aud }}
128130
secrets: inherit

.github/workflows/layers_partitions_deploy.yml

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
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

Comments
 (0)