Skip to content

Commit 1c063d6

Browse files
authored
improv(ci): Automate the SSM Parameter Update step of the release workflow (#4356)
1 parent 551c34c commit 1c063d6

File tree

5 files changed

+51
-35
lines changed

5 files changed

+51
-35
lines changed

.github/scripts/update_layer_arn.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
# see .github/workflows/publish_layer.yml
99

1010

11-
# Get the new layer arn from the first command-line argument
12-
new_layer_arn=$1
13-
if [ -z "$new_layer_arn" ]; then
14-
echo "Usage: $0 <new_layer_arn>"
11+
# Get the new layer version from the first command-line argument
12+
new_version=$1
13+
if [ -z "$new_version" ]; then
14+
echo "Usage: $0 <new_version>"
1515
exit 1
1616
fi
17-
new_version=$(echo $new_layer_arn | sed 's/.*://')
1817

1918
# Find all files with specified extensions in ./docs and ./examples directories
2019
# -type f: only find files (not directories)

.github/workflows/publish_layer.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ jobs:
8080
secrets:
8181
target-account-role: ${{ secrets.AWS_LAYERS_PROD_ROLE_ARN }}
8282

83+
update-ssm-prod:
84+
needs: [deploy-prod]
85+
uses: ./.github/workflows/update_ssm.yml
86+
permissions:
87+
contents: read
88+
with:
89+
environment: prod
90+
package_version: ${{ inputs.latest_published_version }}
91+
layer-version: ${{ needs.deploy-prod.outputs.layer-version }}
92+
8393
update_layer_arn_docs:
8494
needs: [deploy-prod]
8595
# Force Github action to run only a single job at a time (based on the group name)
@@ -98,7 +108,7 @@ jobs:
98108
ref: ${{ github.sha }}
99109
- name: Replace layer versions in documentation
100110
run: |
101-
./.github/scripts/update_layer_arn.sh ${{ needs.deploy-prod.outputs.layer-arn }}
111+
./.github/scripts/update_layer_arn.sh ${{ needs.deploy-prod.outputs.layer-version }}
102112
- name: Stage changes
103113
run: git add .
104114
- name: Create PR

.github/workflows/reusable_deploy_layer_stack.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ on:
1616
required: true
1717
type: string
1818
outputs:
19-
layer-arn:
20-
description: "The latest deployed Layer ARN"
21-
value: ${{ jobs.deploy-cdk-stack.outputs.layer-arn }}
19+
layer-version:
20+
description: "The latest deployed Layer version"
21+
value: ${{ jobs.deploy-cdk-stack.outputs.layer-version }}
2222
secrets:
2323
target-account-role:
2424
required: true
@@ -70,7 +70,7 @@ jobs:
7070
"mx-central-1"
7171
]
7272
outputs:
73-
layer-arn: ${{ steps.store-latest-layer-arn.outputs.layer-arn }}
73+
layer-version: ${{ steps.store-latest-layer-arn.outputs.layer-version }}
7474
steps:
7575
- name: checkout
7676
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -100,10 +100,11 @@ jobs:
100100
run: |
101101
mkdir cdk-layer-stack
102102
jq -r -c '.LayerPublisherStack.LatestLayerArn' layers/cdk-outputs.json > cdk-layer-stack/${{ matrix.region }}-layer-version.txt
103+
layer_arn=$(cat cdk-layer-stack/${{ matrix.region }}-layer-version.txt)
104+
echo "$layer_arn"
103105
if [ "${{ matrix.region }}" = "us-east-1" ]; then
104-
echo "layer-arn=$(cat cdk-layer-stack/${{ matrix.region }}-layer-version.txt)" | tee -a "$GITHUB_OUTPUT"
105-
else
106-
cat cdk-layer-stack/${{ matrix.region }}-layer-version.txt
106+
layer_version=$(echo $layer_arn | sed 's/.*://')
107+
echo "layer-version=$layer_version" >> "$GITHUB_OUTPUT"
107108
fi
108109
- name: Save Layer ARN artifact
109110
if: ${{ inputs.stage == 'PROD' }}

.github/workflows/update_ssm.yml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# * environment: will prefix /beta/ into the parameter
66
# * write_latest: will create a latest alias instead of a version number in the parameter
77
# * package_version: semantic version number of the released layer (3.x.y)
8-
# * layer_version: this is sequential layer version from the ARN
98
#
109
# A successful parameter would look similar to:
1110
# /aws/service/powertools/python/arm64/python3.8/3.1.0
@@ -27,8 +26,8 @@ on:
2726
description: Environment to deploy to
2827
type: choice
2928
options:
30-
- Beta
31-
- Prod
29+
- beta
30+
- prod
3231
required: true
3332

3433
write_latest:
@@ -41,8 +40,29 @@ on:
4140
type: string
4241
required: true
4342

44-
layer_version:
45-
description: Layer version
43+
layer-version:
44+
description: Layer version of the published layer
45+
type: string
46+
required: true
47+
48+
workflow_call:
49+
inputs:
50+
environment:
51+
description: Environment to deploy to
52+
type: string
53+
required: true
54+
55+
write_latest:
56+
description: Write to the latest path
57+
type: boolean
58+
required: false
59+
60+
package_version:
61+
description: Semantic Version of published layer
62+
type: string
63+
required: true
64+
layer-version:
65+
description: Layer version of the published layer
4666
type: string
4767
required: true
4868

@@ -111,11 +131,11 @@ jobs:
111131
env:
112132
prefix: ${{ inputs.environment == 'beta' && '/aws/service/powertools/beta' || '/aws/service/powertools' }}
113133
run: |
114-
aws ssm put-parameter --name ${{ env.prefix }}/typescript/generic/all/${{ inputs.package_version }} --value "arn:aws:lambda:${{ matrix.region }}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:${{ inputs.layer_version }}" --type String --overwrite
134+
aws ssm put-parameter --name ${{ env.prefix }}/typescript/generic/all/${{ inputs.package_version }} --value "arn:aws:lambda:${{ matrix.region }}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:${{ inputs.layer-version }}" --type String --overwrite
115135
116136
- id: write-latest
117137
if: inputs.write_latest == true
118138
env:
119139
prefix: ${{ inputs.environment == 'beta' && '/aws/service/powertools/beta' || '/aws/service/powertools' }}
120140
run: |
121-
aws ssm put-parameter --name ${{ env.prefix }}/typescript/generic/all/latest --value "arn:aws:lambda:${{ matrix.region }}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:${{ inputs.layer_version }}" --type String --overwrite
141+
aws ssm put-parameter --name ${{ env.prefix }}/typescript/generic/all/latest --value "arn:aws:lambda:${{ matrix.region }}:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:${{ inputs.layer-version }}" --type String --overwrite

docs/maintainers.md

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -190,21 +190,7 @@ targeting the `Prod` deployment environment and the China partition, and using t
190190
This will publish the Lambda layer to the AWS China (Beijing) Region.
191191
9. **Merge docs PR**: Once the `Layer Deployment (Partition)` workflow for the production China partition is complete,
192192
merge the PR from step 4 to update the documentation with the new version.
193-
10. **Update SSM Parameters (Beta)**: Run the `SSM Parameters` workflow with the `main` branch, targeting the `beta`
194-
deployment environment, and using the package version from npm (i.e., `2.20.0`) and Lambda layer version from step 4.
195-
This will update the SSM parameters with the new version.
196-
11. **Verify SSM Parameters (Beta)**: Use the AWS CLI to verify that the SSM parameters were updated correctly. Run
197-
the following command: `aws ssm get-parameter --name=/aws/service/powertools/beta/typescript/generic/all/latest`
198-
and `aws ssm get-parameter --name=/aws/service/powertools/beta/typescript/generic/all/<version>` to verify that the
199-
SSM parameters were updated correctly.
200-
12. **Update SSM Parameters (Prod)**: Run the `SSM Parameters` workflow with the `main` branch, targeting the `prod`
201-
deployment environment, and using the package version from npm (i.e., `2.20.0`) and Lambda layer version from step 4.
202-
This will update the SSM parameters with the new version.
203-
13. **Verify SSM Parameters (Prod)**: Use the AWS CLI to verify that the SSM parameters were updated correctly. Run
204-
the following command: `aws ssm get-parameter --name=/aws/service/powertools/typescript/generic/all/latest`
205-
and `aws ssm get-parameter --name=/aws/service/powertools/typescript/generic/all/<version>` to verify that the
206-
SSM parameters were updated correctly.
207-
14. **Update Docs**: Run the `Rebuild latest docs` workflow with the `main` branch using the package version from
193+
10. **Update Docs**: Run the `Rebuild latest docs` workflow with the `main` branch using the package version from
208194
npm (i.e. `2.20.0`). This will update the documentation with the new version.
209195

210196
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)