Skip to content

Commit 60bf96e

Browse files
sdangolsvozza
andauthored
improv(ci): verify output of Layer deployment (Partitions) GitHub Action (aws-powertools#4308)
Co-authored-by: Stefano Vozza <[email protected]>
1 parent 5d5c602 commit 60bf96e

File tree

2 files changed

+33
-28
lines changed

2 files changed

+33
-28
lines changed

.github/workflows/layers_partitions.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
# We pull each the version of the layer and store them as artifacts, the we upload them to each of the Partitioned AWS accounts.
66
#
77
# A number of safety checks are performed to ensure safety.
8+
#
9+
# === Automated activities ===
10+
# 1. [Setup] configure partition-specific regions, partition names, and STS audience based on target partition (China/GovCloud)
11+
# 2. [Download] retrieve the specified layer version from the main AWS partition (us-east-1) and store as artifacts
12+
# 3. [Copy & Verify] deploy the layer to all regions in the target partition and validate layer deployment by comparing SHA256, description, and version numbers
13+
#
14+
# === Manual activities ===
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+
# 2. Monitor deployment progress and verify successful layer publication across all target regions
17+
# 3. Once this workflow is completed, the PR for the documentation update can me merged
818

919
on:
1020
workflow_dispatch:
@@ -44,6 +54,7 @@ permissions:
4454
contents: read
4555

4656
jobs:
57+
# This job configures partition-specific settings including regions, partition names, and STS audience based on the target partition (China or GovCloud) selected in the workflow inputs.
4758
setup:
4859
runs-on: ubuntu-latest
4960
outputs:
@@ -65,6 +76,7 @@ jobs:
6576
echo regions='["us-gov-east-1", "us-gov-west-1"]'>> "$GITHUB_OUTPUT"
6677
echo partition='aws-us-gov'>> "$GITHUB_OUTPUT"
6778
echo aud='sts.amazonaws.com'>> "$GITHUB_OUTPUT"
79+
# This job downloads the specified layer version from the main AWS partition (us-east-1) and stores both the layer zip file and metadata as GitHub Actions artifacts for use in deployment.
6880
download:
6981
runs-on: ubuntu-latest
7082
permissions:
@@ -96,7 +108,7 @@ jobs:
96108
path: AWSLambdaPowertoolsTypeScriptV2.json
97109
retention-days: 1
98110
if-no-files-found: error
99-
111+
# This job deploys the layer to all regions in the target partition using a matrix strategy. It performs integrity checks, publishes the layer, sets public permissions, and validates deployment.
100112
copy:
101113
name: Copy
102114
needs:
@@ -153,6 +165,11 @@ jobs:
153165
--action lambda:GetLayerVersion \
154166
--principal '*' \
155167
--version-number "$LAYER_VERSION"
168+
# This step retrieves the newly deployed layer metadata and compares it against the original source layer:
169+
# 1. SHA256 hash verification - ensures the layer content is identical to the source
170+
# 2. Description validation - confirms the version number in the description matches the source
171+
# 3. Layer Version number verification - validates that the layer version numbers match between source and target
172+
# 4. Tabular comparison output - displays side-by-side comparison of key layer properties
156173
- name: Verify Layer
157174
env:
158175
LAYER_VERSION: ${{ steps.create-layer.outputs.LAYER_VERSION }}
@@ -162,6 +179,12 @@ jobs:
162179
REMOTE_SHA=$(jq -r '.Content.CodeSha256' $layer_output)
163180
LOCAL_SHA=$(jq -r '.Content.CodeSha256' AWSLambdaPowertoolsTypeScriptV2.json)
164181
test "$REMOTE_SHA" == "$LOCAL_SHA" && echo "SHA OK: ${LOCAL_SHA}" || exit 1
182+
REMOTE_DESCRIPTION=$(jq -r '.Description' $layer_output)
183+
LOCAL_DESCRIPTION=$(jq -r '.Description' AWSLambdaPowertoolsTypeScriptV2.json)
184+
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
165188
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'
166189
167190
- name: Store Metadata - ${{ matrix.region }}

docs/maintainers.md

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -179,50 +179,32 @@ layer version that was deployed, as this will be used in the next steps.
179179
5. **Publish GovCloud Layers (Gamma)**: Run the `Layer Deployment (Partitions)` workflow with the `main` branch,
180180
targeting the `Gamma` deployment environment and the GovCloud partition, using the Lambda layer version from the
181181
step 4. This will publish the Lambda layers to the AWS GovCloud (US-East) and AWS GovCloud (US-West) Regions.
182-
6. **Verify GovCloud Layers (Gamma)**: Download the `AWSLambdaPowertoolsTypeScriptV2-us-gov-east-1.json` and
183-
`AWSLambdaPowertoolsTypeScriptV2-us-gov-west-1.json` ZIP files. Unzip the files, inspect the JSON files therein and
184-
ensure the version number in the `Description` field (i.e., `Powertools for AWS Lambda (TypeScript) version 2.20.0`)
185-
and the layer version in the `LayerVersionArn` field (i.e., `arn:aws-us-gov:lambda:us-gov-east-1:164754790254:layer:AWSLambdaPowertoolsTypeScriptV2:32`)
186-
are correct.
187-
7. **Publish GovCloud Layers (Prod)**: Run the `Layer Deployment (Partitions)` workflow with the `main` branch,
182+
6. **Publish GovCloud Layers (Prod)**: Run the `Layer Deployment (Partitions)` workflow with the `main` branch,
188183
targeting the `Prod` deployment environment and the GovCloud partition, using the Lambda layer version from step 4.
189184
This will publish the Lambda layers to the AWS GovCloud (US-East) and AWS GovCloud (US-West) Regions.
190-
8. **Verify GovCloud Layers (Prod)**: Download the `AWSLambdaPowertoolsTypeScriptV2-us-gov-east-1.json` and
191-
`AWSLambdaPowertoolsTypeScriptV2-us-gov-west-1.json` ZIP files. Unzip the files, inspect the JSON files therein and
192-
ensure the version number in the `Description` field (i.e., `Powertools for AWS Lambda (TypeScript) version 2.20.0`)
193-
and the layer version in the `LayerVersionArn` field (i.e., `arn:aws-us-gov:lambda:us-gov-west-1:165093116878:layer:AWSLambdaPowertoolsTypeScriptV2:32`)
194-
are correct.
195-
9. **Publish China Layer (Gamma)**: Run the `Layer Deployment (Partitions)` workflow with the `main` branch, targeting
185+
7. **Publish China Layer (Gamma)**: Run the `Layer Deployment (Partitions)` workflow with the `main` branch, targeting
196186
the `Gamma` deployment environment and the China partition, using the Lambda layer version from step 4. This will
197187
publish the Lambda layer to the AWS China (Beijing) Region.
198-
10. **Verify China Layer (Gamma)**: Download the `AWSLambdaPowertoolsTypeScriptV2-cn-north-1.json` ZIP file. Unzip
199-
the file, inspect the JSON file therein and ensure the version number in the `Description` field
200-
(i.e., `Powertools for AWS Lambda (TypeScript) version 2.20.0`) and the layer version in the `LayerVersionArn` field
201-
(i.e., `arn:aws-cn:lambda:cn-north-1:498595349401:layer:AWSLambdaPowertoolsTypeScriptV2:32`) are correct.
202-
11. **Publish China Layer (Prod)**: Run the `Layer Deployment (Partitions)` workflow with the `main` branch,
188+
8. **Publish China Layer (Prod)**: Run the `Layer Deployment (Partitions)` workflow with the `main` branch,
203189
targeting the `Prod` deployment environment and the China partition, and using the Lambda layer version from step 4.
204190
This will publish the Lambda layer to the AWS China (Beijing) Region.
205-
12. **Verify China Layer (Prod)**: Download the `AWSLambdaPowertoolsTypeScriptV2-cn-north-1.json` ZIP file. Unzip the
206-
file, inspect the JSON file therein and ensure the version number in the `Description` field
207-
(i.e., `Powertools for AWS Lambda (TypeScript) version 2.20.0`) and the layer version in the `LayerVersionArn`
208-
field (i.e., `arn:aws-cn:lambda:cn-north-1:498634801083:layer:AWSLambdaPowertoolsTypeScriptV2:32`) are correct.
209-
13. **Merge docs PR**: Once the `Layer Deployment (Partition)` workflow for the production China partition is complete,
191+
9. **Merge docs PR**: Once the `Layer Deployment (Partition)` workflow for the production China partition is complete,
210192
merge the PR from step 4 to update the documentation with the new version.
211-
14. **Update SSM Parameters (Beta)**: Run the `SSM Parameters` workflow with the `main` branch, targeting the `beta`
193+
10. **Update SSM Parameters (Beta)**: Run the `SSM Parameters` workflow with the `main` branch, targeting the `beta`
212194
deployment environment, and using the package version from npm (i.e., `2.20.0`) and Lambda layer version from step 4.
213195
This will update the SSM parameters with the new version.
214-
15. **Verify SSM Parameters (Beta)**: Use the AWS CLI to verify that the SSM parameters were updated correctly. Run
196+
11. **Verify SSM Parameters (Beta)**: Use the AWS CLI to verify that the SSM parameters were updated correctly. Run
215197
the following command: `aws ssm get-parameter --name=/aws/service/powertools/beta/typescript/generic/all/latest`
216198
and `aws ssm get-parameter --name=/aws/service/powertools/beta/typescript/generic/all/<version>` to verify that the
217199
SSM parameters were updated correctly.
218-
16. **Update SSM Parameters (Prod)**: Run the `SSM Parameters` workflow with the `main` branch, targeting the `prod`
200+
12. **Update SSM Parameters (Prod)**: Run the `SSM Parameters` workflow with the `main` branch, targeting the `prod`
219201
deployment environment, and using the package version from npm (i.e., `2.20.0`) and Lambda layer version from step 4.
220202
This will update the SSM parameters with the new version.
221-
17. **Verify SSM Parameters (Prod)**: Use the AWS CLI to verify that the SSM parameters were updated correctly. Run
203+
13. **Verify SSM Parameters (Prod)**: Use the AWS CLI to verify that the SSM parameters were updated correctly. Run
222204
the following command: `aws ssm get-parameter --name=/aws/service/powertools/typescript/generic/all/latest`
223205
and `aws ssm get-parameter --name=/aws/service/powertools/typescript/generic/all/<version>` to verify that the
224206
SSM parameters were updated correctly.
225-
18. **Update Docs**: Run the `Rebuild latest docs` workflow with the `main` branch using the package version from
207+
14. **Update Docs**: Run the `Rebuild latest docs` workflow with the `main` branch using the package version from
226208
npm (i.e. `2.20.0`). This will update the documentation with the new version.
227209

228210
Once complete, you can start drafting the release notes to let customers know **what changed and what's in it for them (a.k.a why they should care)**. We have guidelines in the release notes section so you know what good looks like.

0 commit comments

Comments
 (0)