1
+ # Partition Layer Verification
2
+ # ---
3
+ # This workflow queries the Partition layer info in production only
4
+
5
+ on :
6
+ workflow_dispatch :
7
+ inputs :
8
+ environment :
9
+ description : Deployment environment
10
+ type : choice
11
+ options :
12
+ - Gamma
13
+ - Prod
14
+ required : true
15
+ version :
16
+ description : Layer version to verify
17
+ type : string
18
+ required : true
19
+ partition_version :
20
+ description : Layer version to verify, this is mostly used in Gamma where a version mismatch might exist
21
+ type : string
22
+ required : false
23
+ partition :
24
+ description : Partition to deploy to
25
+ type : choice
26
+ options :
27
+ - China
28
+ - GovCloud
29
+ workflow_call :
30
+ inputs :
31
+ environment :
32
+ description : Deployment environment
33
+ type : string
34
+ required : true
35
+ version :
36
+ description : Layer version to verify
37
+ type : string
38
+ required : true
39
+ partition_version :
40
+ description : Partition Layer version to verify, this is mostly used in Gamma where a version mismatch might exist
41
+ type : string
42
+ required : false
43
+
44
+ name : Layer Verification (Partition)
45
+ run-name : Layer Verification (${{ inputs.partition }}) - ${{ inputs.environment }} / Version - ${{ inputs.version }}
46
+
47
+ permissions : {}
48
+
49
+ jobs :
50
+ setup :
51
+ runs-on : ubuntu-latest
52
+ outputs :
53
+ regions : ${{ format('{0}{1}', steps.regions_china.outputs.regions, steps.regions_govcloud.outputs.regions) }}
54
+ partition : ${{ format('{0}{1}', steps.regions_china.outputs.partition, steps.regions_govcloud.outputs.partition) }}
55
+ aud : ${{ format('{0}{1}', steps.regions_china.outputs.aud, steps.regions_govcloud.outputs.aud) }}
56
+ steps :
57
+ - id : regions_china
58
+ name : Partition (China)
59
+ if : ${{ inputs.partition == 'China' }}
60
+ run : |
61
+ echo regions='["cn-north-1"]'>> "$GITHUB_OUTPUT"
62
+ echo partition='aws-cn'>> "$GITHUB_OUTPUT"
63
+ echo aud='sts.amazonaws.com.cn'>> "$GITHUB_OUTPUT"
64
+ - id : regions_govcloud
65
+ name : Partition (GovCloud)
66
+ if : ${{ inputs.partition == 'GovCloud' }}
67
+ run : |
68
+ echo regions='["us-gov-east-1", "us-gov-west-1"]'>> "$GITHUB_OUTPUT"
69
+ echo partition='aws-us-gov'>> "$GITHUB_OUTPUT"
70
+ echo aud='sts.amazonaws.com'>> "$GITHUB_OUTPUT"
71
+ commercial :
72
+ runs-on : ubuntu-latest
73
+ permissions :
74
+ id-token : write
75
+ contents : read
76
+ environment : Prod (Readonly)
77
+ strategy :
78
+ matrix :
79
+ layer :
80
+ - AWSLambdaPowertoolsPythonV3-python39
81
+ - AWSLambdaPowertoolsPythonV3-python310
82
+ - AWSLambdaPowertoolsPythonV3-python311
83
+ - AWSLambdaPowertoolsPythonV3-python312
84
+ - AWSLambdaPowertoolsPythonV3-python313
85
+ arch :
86
+ - arm64
87
+ - x86_64
88
+ steps :
89
+ - name : Configure AWS Credentials
90
+ uses : aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df # v4.2.1
91
+ with :
92
+ role-to-assume : ${{ secrets.AWS_IAM_ROLE }}
93
+ aws-region : us-east-1
94
+ mask-aws-account-id : true
95
+ - name : Output ${{ matrix.layer }}-${{ matrix.arch }}
96
+ # fetch the specific layer version information from the us-east-1 commercial region
97
+ run : |
98
+ aws --region us-east-1 lambda get-layer-version-by-arn --arn 'arn:aws:lambda:us-east-1:017000801446:layer:${{ matrix.layer }}-${{ matrix.arch }}:${{ inputs.version }}' > '${{ matrix.layer }}-${{ matrix.arch }}.json'
99
+ - name : Store Metadata
100
+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
101
+ with :
102
+ name : ${{ matrix.layer }}-${{ matrix.arch }}.json
103
+ path : ${{ matrix.layer }}-${{ matrix.arch }}.json
104
+ retention-days : 1
105
+ if-no-files-found : error
106
+
107
+ verify :
108
+ name : Verify
109
+ needs :
110
+ - setup
111
+ - commercial
112
+ runs-on : ubuntu-latest
113
+ permissions :
114
+ id-token : write
115
+ contents : read
116
+ # Environment should interperlate as "GovCloud Prod" or "China Beta"
117
+ environment : ${{ inputs.partition }} ${{ inputs.environment }}
118
+ strategy :
119
+ matrix :
120
+ region : ${{ fromJson(needs.setup.outputs.regions) }}
121
+ layer :
122
+ - AWSLambdaPowertoolsPythonV3-python39
123
+ - AWSLambdaPowertoolsPythonV3-python310
124
+ - AWSLambdaPowertoolsPythonV3-python311
125
+ - AWSLambdaPowertoolsPythonV3-python312
126
+ - AWSLambdaPowertoolsPythonV3-python313
127
+ arch :
128
+ - arm64
129
+ - x86_64
130
+ steps :
131
+ - name : Download Metadata
132
+ uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
133
+ with :
134
+ name : ${{ matrix.layer }}-${{ matrix.arch }}.json
135
+ - id : transform
136
+ run : |
137
+ echo 'CONVERTED_REGION=${{ matrix.region }}' | tr 'a-z\-' 'A-Z_' >> "$GITHUB_OUTPUT"
138
+ - name : Configure AWS Credentials
139
+ uses : aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df # v4.2.1
140
+ with :
141
+ role-to-assume : ${{ secrets[format('IAM_ROLE_{0}', steps.transform.outputs.CONVERTED_REGION)] }}
142
+ aws-region : ${{ matrix.region}}
143
+ mask-aws-account-id : true
144
+ audience : ${{ needs.setup.outputs.aud }}
145
+ - id : partition_version
146
+ name : Partition Layer Version
147
+ run : |
148
+ echo 'partition_version=$([[ -n "${{ inputs.partition_version}}" ]] && echo ${{ inputs.partition_version}} || echo ${{ inputs.version }} )' >> "$GITHUB_OUTPUT"
149
+ - name : Verify Layer
150
+ run : |
151
+ export layer_output='${{ matrix.layer }}-${{ matrix.arch }}-${{matrix.region}}.json'
152
+ aws --region ${{ matrix.region}} lambda get-layer-version-by-arn --arn "arn:${{ needs.setup.outputs.partition }}:lambda:${{ matrix.region}}:${{ secrets[format('AWS_ACCOUNT_{0}', steps.transform.outputs.CONVERTED_REGION)] }}:layer:${{ matrix.layer }}-${{ matrix.arch }}:${{ steps.partition_version.outputs.partition_version }}" > $layer_output
153
+ REMOTE_SHA=$(jq -r '.Content.CodeSha256' $layer_output)
154
+ LOCAL_SHA=$(jq -r '.Content.CodeSha256' ${{ matrix.layer }}-${{ matrix.arch }}.json)
155
+ test "$REMOTE_SHA" == "$LOCAL_SHA" && echo "SHA OK: ${LOCAL_SHA}" || exit 1
156
+ jq -s -r '["Layer Arn", "Runtimes", "Version", "Description", "SHA256"], ([.[0], .[1]] | .[] | [.LayerArn, (.CompatibleRuntimes | join("/")), .Version, .Description, .Content.CodeSha256]) |@tsv' ${{ matrix.layer }}-${{ matrix.arch }}.json $layer_output | column -t -s $'\t'
0 commit comments