-
Notifications
You must be signed in to change notification settings - Fork 0
CCM-15258 - Event target subscription changes #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
903c26c
93c047b
bc7a267
b7c03b4
37b6a72
ceca908
f120379
b9643b3
05263ef
7296777
17f648e
8f98575
99c27f6
6d72254
a0198e8
69d8c9a
8cb566a
724a2f8
9e03a52
6c8e74b
d029cb2
c5709e4
55ba575
7f45666
02262d0
bb50c8a
b8155b4
c940c63
18d302f
0aa1306
06063da
e42b1db
e48737f
8ad15bf
12903fb
aeb82e9
36fd5a6
c8dd303
408507b
986b4ab
0744e32
9ce6a37
c7909a3
fa2b05c
d5c7e6c
6c41ab4
f4dadbe
50b07cf
aab9364
313ba66
ec282bd
3c3abd3
14b74c7
7bf9fb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| # # This script is run before the Terraform apply command. | ||
| # # It ensures all Node.js dependencies are installed, generates any required dependencies, | ||
| # # and builds all Lambda functions in the workspace before Terraform provisions infrastructure. | ||
| # This script is run before the Terraform apply command. | ||
| # It ensures dependencies are installed, generates local client config files | ||
| # for terraform from S3-held subscriptions, and builds lambda workspaces. | ||
|
|
||
| script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
|
||
| npm ci | ||
|
|
||
| npm run generate-dependencies --workspaces --if-present | ||
|
|
||
| "${script_dir}/sync-client-config.sh" | ||
|
|
||
| npm run lambda-build --workspaces --if-present |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice if this script could just copy mock-client.json in - this would simplify some of the terraform in |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # This script seeds local client subscription JSON files from the config bucket | ||
| # before Terraform evaluates locals/fileset (see local.config_clients in locals.tf). | ||
| # It handles the S3 bucket not existing on first apply. | ||
| # Deployment Lifecycle: | ||
| # - Sync client JSON files from S3 into "modules/clients" before Terraform runs. | ||
| # - Terraform then reads the local fileset from "modules/clients" as input. | ||
| # - On later deployments, files are refreshed from bucket state each run. | ||
| # | ||
| # Deployment Lifecycle dev/test environment: | ||
| # - Special handling is needed to seed test data and have it take effect on the first apply, as the bucket and files won't exist yet | ||
| # - Terraform merges in the local mock fixture config into local.config_clients | ||
| # - Terraform uploads mock-it-client.json to the config bucket | ||
| # - On subsequent deployments, that mock config is synced from S3 and handled | ||
| # through the normal fileset path. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| repo_root="$(cd "${script_dir}/../../../.." && pwd)" | ||
| clients_dir="${repo_root}/infrastructure/terraform/modules/clients" | ||
|
|
||
| : "${ENVIRONMENT:?ENVIRONMENT must be set}" | ||
| : "${AWS_REGION:?AWS_REGION must be set}" | ||
| : "${AWS_ACCOUNT_ID:?AWS_ACCOUNT_ID must be set}" | ||
|
|
||
| cd "${repo_root}" | ||
|
|
||
| rm -f "${clients_dir}"/*.json | ||
|
|
||
| bucket_name="nhs-${AWS_ACCOUNT_ID}-${AWS_REGION}-${ENVIRONMENT}-callbacks-subscription-config" | ||
|
|
||
| s3_prefix="client_subscriptions/" | ||
|
|
||
| echo "Seeding client configs from s3://${bucket_name}/${s3_prefix} for ${ENVIRONMENT}/${AWS_REGION}" | ||
|
|
||
| if ! sync_output=$(aws s3 sync "s3://${bucket_name}/${s3_prefix}" "${clients_dir}/" \ | ||
| --region "${AWS_REGION}" \ | ||
| --exclude "*" \ | ||
| --include "*.json" \ | ||
| --only-show-errors 2>&1); then | ||
| if [[ "${sync_output}" == *"NoSuchBucket"* ]]; then | ||
| # Expected on first apply before Terraform creates the bucket. | ||
| echo "Client config bucket not found yet; skipping sync for first run" | ||
| else | ||
| echo "Failed to sync client config from S3" >&2 | ||
| echo "${sync_output}" >&2 | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| # Ensure an empty directory produces a zero-length array rather than a literal "*.json" entry. | ||
| shopt -s nullglob | ||
| seeded_files=("${clients_dir}"/*.json) | ||
| seeded_count="${#seeded_files[@]}" | ||
| shopt -u nullglob | ||
|
|
||
| echo "Seeded ${seeded_count} client config file(s)" |
Uh oh!
There was an error while loading. Please reload this page.