@@ -103,9 +103,9 @@ jobs:
103103 - name : " Get S3 bucket name"
104104 id : bucket
105105 run : |
106- cd infrastructure/stacks/api-layer
107- terraform init -backend=true
108- BUCKET=$(terraform output -raw lambda_artifact_bucket)
106+ cd infrastructure
107+ make terraform env=dev stack=api-layer tf-command=init workspace=default
108+ BUCKET=$(terraform -chdir=./stacks/api-layer output -raw lambda_artifact_bucket)
109109 echo "name=$BUCKET" >> $GITHUB_OUTPUT
110110 echo "📦 S3 Bucket: $BUCKET"
111111
@@ -124,6 +124,25 @@ jobs:
124124 echo "exists=false" >> $GITHUB_OUTPUT
125125 fi
126126
127+ - name : " Download artifact for workflow reuse"
128+ if : steps.check.outputs.exists == 'true'
129+ run : |
130+ TAG="${{ needs.validate.outputs.dev_tag }}"
131+ BUCKET="${{ steps.bucket.outputs.name }}"
132+ mkdir -p ./dist
133+ aws s3 cp \
134+ "s3://$BUCKET/artifacts/$TAG/lambda.zip" \
135+ ./dist/lambda.zip \
136+ --region eu-west-2
137+
138+ - name : " Upload lambda artifact"
139+ if : steps.check.outputs.exists == 'true'
140+ uses : actions/upload-artifact@v4
141+ with :
142+ name : lambda-${{ needs.validate.outputs.dev_tag }}
143+ path : dist/lambda.zip
144+ if-no-files-found : error
145+
127146 rebuild-artifact :
128147 name : " Rebuild and upload artifact (if missing)"
129148 runs-on : ubuntu-latest
@@ -165,6 +184,13 @@ jobs:
165184 --region eu-west-2
166185 echo "✅ Uploaded artifact to s3://$BUCKET/artifacts/$TAG/lambda.zip"
167186
187+ - name : " Upload lambda artifact"
188+ uses : actions/upload-artifact@v4
189+ with :
190+ name : lambda-${{ needs.validate.outputs.dev_tag }}
191+ path : dist/lambda.zip
192+ if-no-files-found : error
193+
168194 deploy-to-test :
169195 name : " Deploy to Test (optional)"
170196 runs-on : ubuntu-latest
@@ -189,21 +215,11 @@ jobs:
189215 with :
190216 terraform_version : $(grep '^terraform' .tool-versions | cut -f2 -d' ')
191217
192- - name : " Configure AWS Credentials (dev) - to download artifact"
193- uses : aws- actions/configure-aws-credentials@v5
218+ - name : " Download lambda artifact"
219+ uses : actions/download-artifact@v4
194220 with :
195- role-to-assume : arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role
196- aws-region : eu-west-2
197-
198- - name : " Download lambda from S3 (dev bucket)"
199- run : |
200- TAG="${{ needs.validate.outputs.dev_tag }}"
201- BUCKET="${{ needs.verify-artifact.outputs.s3_bucket }}"
202- mkdir -p ./dist
203- aws s3 cp \
204- "s3://$BUCKET/artifacts/$TAG/lambda.zip" \
205- ./dist/lambda.zip \
206- --region eu-west-2
221+ name : lambda-${{ needs.validate.outputs.dev_tag }}
222+ path : dist
207223
208224 - name : " Configure AWS Credentials (test)"
209225 uses : aws-actions/configure-aws-credentials@v5
@@ -220,6 +236,7 @@ jobs:
220236 TF_VAR_API_PRIVATE_KEY_CERT : ${{ secrets.API_PRIVATE_KEY_CERT }}
221237 TF_VAR_SPLUNK_HEC_TOKEN : ${{ secrets.SPLUNK_HEC_TOKEN }}
222238 TF_VAR_SPLUNK_HEC_ENDPOINT : ${{ secrets.SPLUNK_HEC_ENDPOINT }}
239+ TF_VAR_OPERATOR_EMAILS : ${{ vars.SECRET_ROTATION_OPERATOR_EMAILS }}
223240 run : |
224241 mkdir -p ./build
225242 echo "🚀 Deploying ${{ needs.validate.outputs.dev_tag }} to TEST"
@@ -237,8 +254,9 @@ jobs:
237254 - name : " Get test S3 bucket"
238255 id : test_bucket
239256 run : |
240- cd infrastructure/stacks/api-layer
241- BUCKET=$(terraform output -raw lambda_artifact_bucket)
257+ cd infrastructure
258+ make terraform env=test stack=api-layer tf-command=init workspace=default
259+ BUCKET=$(terraform -chdir=./stacks/api-layer output -raw lambda_artifact_bucket)
242260 echo "name=$BUCKET" >> $GITHUB_OUTPUT
243261
244262 - name : " Upload lambda to test S3"
@@ -295,42 +313,11 @@ jobs:
295313 with :
296314 terraform_version : $(grep '^terraform' .tool-versions | cut -f2 -d' ')
297315
298- - name : " Determine source bucket (test or dev)"
299- id : source
300- run : |
301- if [[ "${{ inputs.deploy_to_test }}" == "true" ]]; then
302- echo "environment=test" >> $GITHUB_OUTPUT
303- else
304- echo "environment=dev" >> $GITHUB_OUTPUT
305- fi
306-
307- - name : " Configure AWS Credentials (source) - to download artifact"
308- uses : aws-actions/configure-aws-credentials@v5
316+ - name : " Download lambda artifact"
317+ uses : actions/download-artifact@v4
309318 with :
310- role-to-assume : arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role
311- aws-region : eu-west-2
312-
313- - name : " Get source S3 bucket"
314- id : source_bucket
315- env :
316- ENV : ${{ steps.source.outputs.environment }}
317- run : |
318- cd infrastructure
319- make terraform env=$ENV stack=api-layer tf-command=init workspace=default
320- cd stacks/api-layer
321- BUCKET=$(terraform output -raw lambda_artifact_bucket)
322- echo "name=$BUCKET" >> $GITHUB_OUTPUT
323- echo "📦 Source bucket ($ENV): $BUCKET"
324-
325- - name : " Download lambda from source S3"
326- run : |
327- TAG="${{ needs.validate.outputs.dev_tag }}"
328- BUCKET="${{ steps.source_bucket.outputs.name }}"
329- mkdir -p ./dist
330- aws s3 cp \
331- "s3://$BUCKET/artifacts/$TAG/lambda.zip" \
332- ./dist/lambda.zip \
333- --region eu-west-2
319+ name : lambda-${{ needs.validate.outputs.dev_tag }}
320+ path : dist
334321
335322 - name : " Configure AWS Credentials (preprod)"
336323 uses : aws-actions/configure-aws-credentials@v5
@@ -347,6 +334,7 @@ jobs:
347334 TF_VAR_API_PRIVATE_KEY_CERT : ${{ secrets.API_PRIVATE_KEY_CERT }}
348335 TF_VAR_SPLUNK_HEC_TOKEN : ${{ secrets.SPLUNK_HEC_TOKEN }}
349336 TF_VAR_SPLUNK_HEC_ENDPOINT : ${{ secrets.SPLUNK_HEC_ENDPOINT }}
337+ TF_VAR_OPERATOR_EMAILS : ${{ vars.SECRET_ROTATION_OPERATOR_EMAILS }}
350338 run : |
351339 mkdir -p ./build
352340 echo "🚀 Deploying ${{ needs.validate.outputs.dev_tag }} to PREPROD"
@@ -381,8 +369,9 @@ jobs:
381369 - name : " Get preprod S3 bucket"
382370 id : preprod_bucket
383371 run : |
384- cd infrastructure/stacks/api-layer
385- BUCKET=$(terraform output -raw lambda_artifact_bucket)
372+ cd infrastructure
373+ make terraform env=preprod stack=api-layer tf-command=init workspace=default
374+ BUCKET=$(terraform -chdir=./stacks/api-layer output -raw lambda_artifact_bucket)
386375 echo "name=$BUCKET" >> $GITHUB_OUTPUT
387376
388377 - name : " Upload lambda to preprod S3"
0 commit comments