1
+ name : Layer Deployment (GovCloud)
2
+
3
+ # GovCloud Layer Publish
4
+ # ---
5
+ # This workflow publishes a specific layer version in an AWS account based on the environment input.
6
+ #
7
+ # We pull each the version of the layer and store them as artifacts, the we upload them to each of the GovCloud AWS accounts.
8
+ #
9
+ # A number of safety checks are performed to ensure safety.
10
+
11
+ on :
12
+ workflow_dispatch :
13
+ inputs :
14
+ environment :
15
+ description : Deployment environment
16
+ type : choice
17
+ options :
18
+ - Gamma
19
+ - Prod
20
+ required : true
21
+ version :
22
+ description : Layer version to duplicate
23
+ type : string
24
+ required : true
25
+ workflow_call :
26
+ inputs :
27
+ environment :
28
+ description : Deployment environment
29
+ type : string
30
+ required : true
31
+ version :
32
+ description : Layer version to duplicate
33
+ type : string
34
+ required : true
35
+
36
+ run-name : Layer Deployment (GovCloud) - ${{ inputs.environment }} - version - ${{ inputs.version }}
37
+
38
+ permissions :
39
+ contents : read
40
+
41
+ jobs :
42
+ download :
43
+ runs-on : ubuntu-latest
44
+ permissions :
45
+ id-token : write
46
+ contents : read
47
+ environment : Prod (Readonly)
48
+ steps :
49
+ - name : Configure AWS Credentials
50
+ uses : aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
51
+ with :
52
+ role-to-assume : ${{ secrets.AWS_IAM_ROLE }}
53
+ aws-region : us-east-1
54
+ mask-aws-account-id : true
55
+ - name : Grab Zip
56
+ run : |
57
+ aws --region us-east-1 lambda get-layer-version-by-arn --arn arn:aws:lambda:us-east-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:${{ inputs.version }} --query 'Content.Location' | xargs curl -L -o AWSLambdaPowertoolsTypeScriptV2.zip
58
+ aws --region us-east-1 lambda get-layer-version-by-arn --arn arn:aws:lambda:us-east-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:${{ inputs.version }} > AWSLambdaPowertoolsTypeScriptV2.json
59
+ - name : Store Zip
60
+ uses : actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
61
+ with :
62
+ name : AWSLambdaPowertoolsTypeScriptV2.zip
63
+ path : AWSLambdaPowertoolsTypeScriptV2.zip
64
+ retention-days : 1
65
+ if-no-files-found : error
66
+ - name : Store Metadata
67
+ uses : actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
68
+ with :
69
+ name : AWSLambdaPowertoolsTypeScriptV2.json
70
+ path : AWSLambdaPowertoolsTypeScriptV2.json
71
+ retention-days : 1
72
+ if-no-files-found : error
73
+
74
+ copy_east :
75
+ name : Copy (East)
76
+ needs : download
77
+ runs-on : ubuntu-latest
78
+ permissions :
79
+ id-token : write
80
+ contents : read
81
+ environment : GovCloud ${{ inputs.environment }} (East)
82
+ steps :
83
+ - name : Download Zip
84
+ uses : actions/download-artifact@b14cf4c92620c250e1c074ab0a5800e37df86765 # v4.2.0
85
+ with :
86
+ name : AWSLambdaPowertoolsTypeScriptV2.zip
87
+ - name : Download Metadata
88
+ uses : actions/download-artifact@b14cf4c92620c250e1c074ab0a5800e37df86765 # v4.2.0
89
+ with :
90
+ name : AWSLambdaPowertoolsTypeScriptV2.json
91
+ - name : Verify Layer Signature
92
+ run : |
93
+ SHA=$(jq -r '.Content.CodeSha256' 'AWSLambdaPowertoolsTypeScriptV2.json')
94
+ test "$(openssl dgst -sha256 -binary AWSLambdaPowertoolsTypeScriptV2.zip | openssl enc -base64)" == "$SHA" && echo "SHA OK: ${SHA}" || exit 1
95
+ - name : Configure AWS Credentials
96
+ uses : aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
97
+ with :
98
+ role-to-assume : ${{ secrets.AWS_IAM_ROLE }}
99
+ aws-region : us-gov-east-1
100
+ mask-aws-account-id : true
101
+ - name : Create Layer
102
+ id : create-layer
103
+ run : |
104
+ LAYER_VERSION=$(aws --region us-gov-east-1 lambda publish-layer-version \
105
+ --layer-name AWSLambdaPowertoolsTypeScriptV2 \
106
+ --zip-file fileb://./AWSLambdaPowertoolsTypeScriptV2.zip \
107
+ --compatible-runtimes "$(jq -r '.CompatibleRuntimes[0]' 'AWSLambdaPowertoolsTypeScriptV2.json')" \
108
+ --compatible-architectures "$(jq -r '.CompatibleArchitectures[0]' 'AWSLambdaPowertoolsTypeScriptV2.json')" \
109
+ --license-info "MIT-0" \
110
+ --description "$(jq -r '.Description' 'AWSLambdaPowertoolsTypeScriptV2.json')" \
111
+ --query 'Version' \
112
+ --output text)
113
+
114
+ echo "LAYER_VERSION=$LAYER_VERSION" >> "$GITHUB_OUTPUT"
115
+
116
+ aws --region us-gov-east-1 lambda add-layer-version-permission \
117
+ --layer-name 'AWSLambdaPowertoolsTypeScriptV2' \
118
+ --statement-id 'PublicLayer' \
119
+ --action lambda:GetLayerVersion \
120
+ --principal '*' \
121
+ --version-number "$LAYER_VERSION"
122
+ - name : Verify Layer
123
+ env :
124
+ LAYER_VERSION : ${{ steps.create-layer.outputs.LAYER_VERSION }}
125
+ run : |
126
+ REMOTE_SHA=$(aws --region us-gov-east-1 lambda get-layer-version-by-arn --arn 'arn:aws-us-gov:lambda:us-gov-east-1:${{ secrets.AWS_ACCOUNT_ID }}:layer:AWSLambdaPowertoolsTypeScriptV2:${{ env.LAYER_VERSION }}' --query 'Content.CodeSha256' --output text)
127
+ SHA=$(jq -r '.Content.CodeSha256' 'AWSLambdaPowertoolsTypeScriptV2.json')
128
+ test "$REMOTE_SHA" == "$SHA" && echo "SHA OK: ${SHA}" || exit 1
129
+ aws --region us-gov-east-1 lambda get-layer-version-by-arn --arn 'arn:aws-us-gov:lambda:us-gov-east-1:${{ secrets.AWS_ACCOUNT_ID }}:layer:AWSLambdaPowertoolsTypeScriptV2:${{ env.LAYER_VERSION }}' --output table
130
+
131
+ copy_west :
132
+ name : Copy (West)
133
+ needs : download
134
+ runs-on : ubuntu-latest
135
+ permissions :
136
+ id-token : write
137
+ contents : read
138
+ environment :
139
+ name : GovCloud ${{ inputs.environment }} (West)
140
+ steps :
141
+ - name : Download Zip
142
+ uses : actions/download-artifact@b14cf4c92620c250e1c074ab0a5800e37df86765 # v4.2.0
143
+ with :
144
+ name : AWSLambdaPowertoolsTypeScriptV2.zip
145
+ - name : Download Metadata
146
+ uses : actions/download-artifact@b14cf4c92620c250e1c074ab0a5800e37df86765 # v4.2.0
147
+ with :
148
+ name : AWSLambdaPowertoolsTypeScriptV2.json
149
+ - name : Verify Layer Signature
150
+ run : |
151
+ SHA=$(jq -r '.Content.CodeSha256' 'AWSLambdaPowertoolsTypeScriptV2.json')
152
+ test "$(openssl dgst -sha256 -binary AWSLambdaPowertoolsTypeScriptV2.zip | openssl enc -base64)" == "$SHA" && echo "SHA OK: ${SHA}" || exit 1
153
+ - name : Configure AWS Credentials
154
+ uses : aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
155
+ with :
156
+ role-to-assume : ${{ secrets.AWS_IAM_ROLE }}
157
+ aws-region : us-gov-west-1
158
+ mask-aws-account-id : true
159
+ - name : Create Layer
160
+ id : create-layer
161
+ run : |
162
+ LAYER_VERSION=$(aws --region us-gov-west-1 lambda publish-layer-version \
163
+ --layer-name AWSLambdaPowertoolsTypeScriptV2 \
164
+ --zip-file fileb://./AWSLambdaPowertoolsTypeScriptV2.zip \
165
+ --compatible-runtimes "$(jq -r '.CompatibleRuntimes[0]' 'AWSLambdaPowertoolsTypeScriptV2.json')" \
166
+ --compatible-architectures "$(jq -r '.CompatibleArchitectures[0]' 'AWSLambdaPowertoolsTypeScriptV2.json')" \
167
+ --license-info "MIT-0" \
168
+ --description "$(jq -r '.Description' 'AWSLambdaPowertoolsTypeScriptV2.json')" \
169
+ --query 'Version' \
170
+ --output text)
171
+
172
+ echo "LAYER_VERSION=$LAYER_VERSION" >> "$GITHUB_OUTPUT"
173
+
174
+ aws --region us-gov-west-1 lambda add-layer-version-permission \
175
+ --layer-name 'AWSLambdaPowertoolsTypeScriptV2' \
176
+ --statement-id 'PublicLayer' \
177
+ --action lambda:GetLayerVersion \
178
+ --principal '*' \
179
+ --version-number "$LAYER_VERSION"
180
+ - name : Verify Layer
181
+ env :
182
+ LAYER_VERSION : ${{ steps.create-layer.outputs.LAYER_VERSION }}
183
+ run : |
184
+ REMOTE_SHA=$(aws --region us-gov-west-1 lambda get-layer-version-by-arn --arn 'arn:aws-us-gov:lambda:us-gov-west-1:${{ secrets.AWS_ACCOUNT_ID }}:layer:AWSLambdaPowertoolsTypeScriptV2:${{ env.LAYER_VERSION }}' --query 'Content.CodeSha256' --output text)
185
+ SHA=$(jq -r '.Content.CodeSha256' 'AWSLambdaPowertoolsTypeScriptV2.json')
186
+ test "$REMOTE_SHA" == "$SHA" && echo "SHA OK: ${SHA}" || exit 1
187
+ aws --region us-gov-west-1 lambda get-layer-version-by-arn --arn 'arn:aws-us-gov:lambda:us-gov-west-1:${{ secrets.AWS_ACCOUNT_ID }}:layer:AWSLambdaPowertoolsTypeScriptV2:${{ env.LAYER_VERSION }}' --output table
0 commit comments