@@ -4,14 +4,14 @@ name: Deploy V3 SAR
4
4
#
5
5
# 1. This workflow starts after the layer artifact is produced on `publish_v3_layer`
6
6
# 2. We use the same layer artifact to ensure the SAR app is consistent with the published Lambda Layer
7
- # 3. We publish the SAR for both x86_64 and arm64 (see `matrix` section)
7
+ # 3. We publish the SAR for 3.8 to 3.12 Python runtime and both x86_64 and arm64 (see `matrix` section)
8
8
# 4. We use `sam package` and `sam publish` to publish the SAR app
9
9
# 5. We remove the previous Canary stack (if present) and deploy a new one to test the SAR App. We retain the Canary in the account for debugging purposes
10
10
# 6. Finally the published SAR app is made public on the PROD environment
11
11
12
12
# USAGE
13
13
#
14
- # NOTE: meant to be used with ./.github/workflows/publish_v2_layer .yml
14
+ # NOTE: meant to be used with ./.github/workflows/publish_v3_layer .yml
15
15
#
16
16
# sar-beta:
17
17
# needs: build-layer
@@ -25,7 +25,6 @@ name: Deploy V3 SAR
25
25
# secrets: inherit
26
26
# with:
27
27
# stage: "BETA"
28
- # artefact-name: "cdk-layer-artefact"
29
28
# environment: "layer-beta"
30
29
# package-version: ${{ inputs.latest_published_version }}
31
30
# source_code_artifact_name: ${{ inputs.source_code_artifact_name }}
@@ -36,10 +35,10 @@ permissions:
36
35
contents : read
37
36
38
37
env :
39
- NODE_VERSION : 16.12
38
+ NODE_VERSION : 18.20.4
40
39
AWS_REGION : eu-west-1
41
- SAR_NAME : aws-lambda-powertools-python-layer
42
- TEST_STACK_NAME : serverlessrepo-v2 -powertools-layer-test-stack
40
+ SAR_NAME : aws-lambda-powertools-python-layer # PROBLEM - WE NEED TO TALK
41
+ TEST_STACK_NAME : serverlessrepo-v3 -powertools-layer-test-stack
43
42
RELEASE_COMMIT : ${{ github.sha }} # it gets propagated from the caller for security reasons
44
43
45
44
on :
49
48
description : " Deployment stage (BETA, PROD)"
50
49
required : true
51
50
type : string
52
- artefact-name :
53
- description : " CDK Layer Artefact name to download"
54
- required : true
55
- type : string
56
51
package-version :
57
52
description : " The version of the package to deploy"
58
53
required : true
77
72
strategy :
78
73
matrix :
79
74
architecture : ["x86_64", "arm64"]
75
+ python-version : ["3.8","3.9","3.10","3.11","3.12"]
80
76
steps :
81
77
- name : checkout
82
78
uses : actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
@@ -117,14 +113,20 @@ jobs:
117
113
- name : Download artifact
118
114
uses : actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
119
115
with :
120
- name : ${{ inputs.artefact-name }}
116
+ name : cdk-layer-artifact-py ${{ matrix.python-version }}
121
117
- name : Unzip artefact
122
- run : unzip cdk.out.zip
118
+ run : unzip cdk.py${{ matrix.python-version }}.out.zip
119
+ - name : normalize Python Version
120
+ run : |
121
+ PYTHON_VERSION=$(echo ${{ matrix.python-version }} | tr -d '.')
122
+ echo "PYTHON_VERSION=${PYTHON_VERSION}" >> "$GITHUB_ENV"
123
123
- name : Configure SAR name
124
124
run : |
125
125
if [[ "${{ inputs.stage }}" == "BETA" ]]; then
126
126
SAR_NAME="test-${SAR_NAME}"
127
127
fi
128
+ ARCH_NAME=$(echo ${{ matrix.architecture }} | tr -d '_')
129
+ SAR_NAME="${SAR_NAME}-python${{env.PYTHON_VERSION}}-${ARCH_NAME}"
128
130
echo SAR_NAME="${SAR_NAME}" >> "$GITHUB_ENV"
129
131
- name : Adds arm64 suffix to SAR name
130
132
if : ${{ matrix.architecture == 'arm64' }}
@@ -142,31 +144,33 @@ jobs:
142
144
run : |
143
145
# From the generated LayerStack cdk.out artifact, find the layer asset path for the correct architecture.
144
146
# We'll use this as the source directory of our SAR. This way we are re-using the same layer asset for our SAR.
145
- asset=$(jq -jc '.Resources[] | select(.Properties.CompatibleArchitectures == ["${{ matrix.architecture }}"]) | .Metadata."aws:asset:path"' cdk.out/LayerV2Stack.template.json)
147
+ PYTHON_VERSION=$(echo ${{ matrix.python-version }} | tr -d '.')
148
+ asset=$(jq -jc '.Resources[] | select(.Properties.CompatibleArchitectures == ["${{ matrix.architecture }}"]) | .Metadata."aws:asset:path"' "cdk.out/LayerV3Stack-${PYTHON_VERSION}.template.json")
146
149
147
150
# fill in the SAR SAM template
148
151
sed \
149
152
-e "s|<VERSION>|${VERSION}|g" \
150
153
-e "s/<SAR_APP_NAME>/${{ env.SAR_NAME }}/g" \
151
154
-e "s|<LAYER_CONTENT_PATH>|./cdk.out/$asset|g" \
155
+ -e "s|<PYTHON_RUNTIME>|${{ matrix.python-version }}|g" \
156
+ -e "s|<ARCHITECTURE>|${{ matrix.architecture }}|g" \
152
157
layer/sar/template.txt > template.yml
153
158
154
159
# SAR needs a README and a LICENSE, so just copy the ones from the repo
155
160
cp README.md LICENSE "./cdk.out/$asset/"
156
-
157
- # Debug purposes
158
- cat template.yml
159
161
- name : Deploy SAR
160
162
run : |
163
+ # Debug purposes
164
+ cat template.yml
165
+
161
166
# Package the SAR to our SAR S3 bucket, and publish it
162
167
sam package --template-file template.yml --output-template-file packaged.yml --s3-bucket ${{ secrets.AWS_SAR_S3_BUCKET }}
163
168
sam publish --template packaged.yml --region "$AWS_REGION"
164
169
- name : Deploy BETA canary
165
170
if : ${{ inputs.stage == 'BETA' }}
166
171
run : |
167
- if [[ "${{ matrix.architecture }}" == "arm64" ]]; then
168
- TEST_STACK_NAME="${TEST_STACK_NAME}-arm64"
169
- fi
172
+ ARCH_NAME=$(echo ${{ matrix.architecture }} | tr -d '_')
173
+ TEST_STACK_NAME="${TEST_STACK_NAME}-python${{env.PYTHON_VERSION}}-${ARCH_NAME}"
170
174
171
175
echo "Check if stack does not exist"
172
176
stack_exists=$(aws cloudformation list-stacks --query "StackSummaries[?(StackName == '$TEST_STACK_NAME' && StackStatus == 'CREATE_COMPLETE')].{StackId:StackId, StackName:StackName, CreationTime:CreationTime, StackStatus:StackStatus}" --output text)
0 commit comments