Skip to content

Commit

Permalink
chore: solidify lambda functions matrix definition using a configurat…
Browse files Browse the repository at this point in the history
…ion file where we list functions that need to be deployed in production (#699)

Co-authored-by: Pat Heard <[email protected]>
  • Loading branch information
craigzour and patheard authored Jun 20, 2024
1 parent 5d741df commit 4ea0a7f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
14 changes: 14 additions & 0 deletions .github/production-lambda-functions.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
"audit-logs",
"audit-logs-archiver",
"cognito-email-sender",
"cognito-pre-sign-up",
"form-archiver",
"nagware",
"notify-slack",
"reliability",
"reliability-dlq-consumer",
"response-archiver",
"submission",
"vault-integrity"
]
26 changes: 22 additions & 4 deletions .github/workflows/terragrunt-apply-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ jobs:
with:
is-tagged: 'true'

generate-lambda-functions-matrix:
needs: get-version
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.get-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
ref: ${{ env.VERSION }}
- name: Generate matrix
id: generate-matrix
run: |
LAMBDA_ARRAY=$(echo $(cat ./.github/production-lambda-functions.conf) | sed 's/ //g' )
echo "matrix=$LAMBDA_ARRAY" >> $GITHUB_OUTPUT
outputs:
lambda-functions-matrix: ${{ steps.generate-matrix.outputs.matrix }}

# We deploy ECR first to make sure it is available for the 'build-tag-push-lambda-images' job which will be run in parallel with `terragrunt-apply-all-modules`
terragrunt-apply-ecr-only:
needs: get-version
Expand Down Expand Up @@ -77,14 +95,14 @@ jobs:
run: terragrunt apply --terragrunt-non-interactive -auto-approve

build-tag-push-lambda-images:
needs: [get-version, terragrunt-apply-ecr-only]
needs: [get-version, generate-lambda-functions-matrix, terragrunt-apply-ecr-only]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.get-version.outputs.version }}
strategy:
fail-fast: false
matrix:
image: [audit-logs, audit-logs-archiver, cognito-email-sender, cognito-pre-sign-up, form-archiver, nagware, notify-slack, reliability, reliability-dlq-consumer, response-archiver, submission, vault-integrity]
image: ${{ fromJSON(needs.generate-lambda-functions-matrix.outputs.lambda-functions-matrix) }}
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
Expand Down Expand Up @@ -203,14 +221,14 @@ jobs:
run: terragrunt apply --terragrunt-non-interactive -auto-approve

update-lambda-function-image:
needs: [get-version, terragrunt-apply-all-modules]
needs: [get-version, generate-lambda-functions-matrix, terragrunt-apply-all-modules]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.get-version.outputs.version }}
strategy:
fail-fast: false
matrix:
image: [audit-logs, audit-logs-archiver, cognito-email-sender, cognito-pre-sign-up, form-archiver, nagware, notify-slack, reliability, reliability-dlq-consumer, response-archiver, submission, vault-integrity]
image: ${{ fromJSON(needs.generate-lambda-functions-matrix.outputs.lambda-functions-matrix) }}
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
Expand Down
26 changes: 22 additions & 4 deletions .github/workflows/terragrunt-plan-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,33 @@ jobs:
with:
is-tagged: ${{ !startsWith(github.head_ref, 'release-please--') }} # If not the release PR branch, assume it is a revert PR

test-lambda-code:
generate-lambda-functions-matrix:
needs: get-version
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.get-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
ref: ${{ env.VERSION }}
- name: Generate matrix
id: generate-matrix
run: |
LAMBDA_ARRAY=$(echo $(cat ./.github/production-lambda-functions.conf) | sed 's/ //g' )
echo "matrix=$LAMBDA_ARRAY" >> $GITHUB_OUTPUT
outputs:
lambda-functions-matrix: ${{ steps.generate-matrix.outputs.matrix }}

test-lambda-code:
needs: [get-version, generate-lambda-functions-matrix]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.get-version.outputs.version }}
strategy:
fail-fast: false
matrix:
image: [audit-logs, audit-logs-archiver, cognito-email-sender, cognito-pre-sign-up, form-archiver, nagware, notify-slack, reliability, reliability-dlq-consumer, response-archiver, submission, vault-integrity]
image: ${{ fromJSON(needs.generate-lambda-functions-matrix.outputs.lambda-functions-matrix) }}
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
Expand All @@ -73,14 +91,14 @@ jobs:
lambda-name: ${{ matrix.image }}

build-lambda-images:
needs: get-version
needs: [get-version, generate-lambda-functions-matrix]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.get-version.outputs.version }}
strategy:
fail-fast: false
matrix:
image: [audit-logs, audit-logs-archiver, cognito-email-sender, cognito-pre-sign-up, form-archiver, nagware, notify-slack, reliability, reliability-dlq-consumer, response-archiver, submission, vault-integrity]
image: ${{ fromJSON(needs.generate-lambda-functions-matrix.outputs.lambda-functions-matrix) }}
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
Expand Down

0 comments on commit 4ea0a7f

Please sign in to comment.