From 5e954eca4e86d4b3a39adcc90935d79d5d246ce4 Mon Sep 17 00:00:00 2001 From: Michael Harrison Date: Mon, 18 May 2026 17:00:24 +0100 Subject: [PATCH 1/3] CCM-17784: seed demo clients --- .gitignore | 1 + scripts/seed/seed.sh | 48 +++++++++++++++++++++++++++++++++++++++++++ scripts/seed/utils.sh | 21 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100755 scripts/seed/seed.sh create mode 100644 scripts/seed/utils.sh diff --git a/.gitignore b/.gitignore index bda797693c..b73ee50324 100644 --- a/.gitignore +++ b/.gitignore @@ -97,3 +97,4 @@ lambdas/backend-api/src/email/email-template.json .github/copilot-instructions.md test-runs +seed-data.json diff --git a/scripts/seed/seed.sh b/scripts/seed/seed.sh new file mode 100755 index 0000000000..8a01629b96 --- /dev/null +++ b/scripts/seed/seed.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +set -euo pipefail + +root_dir=$(git rev-parse --show-toplevel) + +source "$root_dir/scripts/seed/utils.sh" + +if [ $# -ne 1 ]; then + echo 1>&2 "$0: expected 1 arguments, received $#" + exit 2 +fi + +environment=$1 + +data_file="$root_dir/seed-data.json" + +if [ ! -f "${data_file}" ]; then + echo 1>&2 "Error: Seed data file not found at ${data_file}" + exit 2 +fi + +csi="nhs-notify-${environment}-app" + +client_parameter_namespace=${csi} + +clients=$(jq -c '.clients[]?' "${data_file}") + +while IFS= read -r client; do + if [[ -n "${client}" ]]; then + client_id=$(jq -r '.id' <<< "${client}") + client_name=$(jq -r '.name' <<< "${client}") + + echo + echo "---" + echo "Processing client (${client_name} - ${client_id})" + + echo "Creating client SSM parameter" + put_client_parameter "${client_parameter_namespace}" "${client}" + echo "Created client SSM parameter" + echo + echo "Processed client: (${client_name} - ${client_id})" + fi +done <<< "${clients}" + +echo +echo "---" +echo "Successfully seeded all demo clients" diff --git a/scripts/seed/utils.sh b/scripts/seed/utils.sh new file mode 100644 index 0000000000..613047542a --- /dev/null +++ b/scripts/seed/utils.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +function put_client_parameter() { + local namespace=$1 + local client=$2 + + local client_id=$(jq -r '.id' <<< "${client}") + local campaign_ids=$(jq '.campaignIds' <<< "${client}") + local features=$(jq '.features' <<< "${client}") + local parameter_name="/${namespace}/clients/${client_id}" + local parameter_value=$(jq <<< "{ + \"campaignIds\": ${campaign_ids}, + \"features\": ${features} + }") + + aws ssm put-parameter \ + --name "${parameter_name}" \ + --value "${parameter_value}" \ + --type SecureString \ + --overwrite > /dev/null +} From 72ee2ac0af84772b8cc870340498fcca986b54cd Mon Sep 17 00:00:00 2001 From: Michael Harrison Date: Fri, 22 May 2026 15:04:29 +0100 Subject: [PATCH 2/3] CCM-17784: use basic string for ssm param --- scripts/seed/utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/seed/utils.sh b/scripts/seed/utils.sh index 613047542a..d537bd4c66 100644 --- a/scripts/seed/utils.sh +++ b/scripts/seed/utils.sh @@ -16,6 +16,6 @@ function put_client_parameter() { aws ssm put-parameter \ --name "${parameter_name}" \ --value "${parameter_value}" \ - --type SecureString \ + --type String \ --overwrite > /dev/null } From 268cdda9c859aa5ffb3daf781ee33f0430d14995 Mon Sep 17 00:00:00 2001 From: Michael Harrison Date: Wed, 27 May 2026 11:00:57 +0100 Subject: [PATCH 3/3] CCM-17784: reuse util function --- scripts/sandbox_auth.sh | 8 +++----- scripts/seed/seed.sh | 4 ++-- scripts/seed/utils.sh | 4 +--- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/scripts/sandbox_auth.sh b/scripts/sandbox_auth.sh index 14e0b301c0..ccfaf8caa3 100755 --- a/scripts/sandbox_auth.sh +++ b/scripts/sandbox_auth.sh @@ -4,6 +4,8 @@ set -euo pipefail root_dir=$(git rev-parse --show-toplevel) +source "$root_dir/scripts/seed/utils.sh" + # expect 3 argument to the script if [ $# -ne 2 ]; then echo 1>&2 "$0: expected 2 arguments, received $#" @@ -68,11 +70,7 @@ if [[ "$get_user_command_exit_code" -ne 0 ]]; then if aws ssm get-parameter --name "$client_config_param_name" --with-decryption >/dev/null 2>&1; then echo "Client config parameter already exists: $client_config_param_name" else - aws ssm put-parameter \ - --name "$client_config_param_name" \ - --value "$client_config_param_value" \ - --type String - + put_client_parameter "${client_config_param_name}" "${client_config_param_value}" echo "Created client config parameter: $client_config_param_name" fi diff --git a/scripts/seed/seed.sh b/scripts/seed/seed.sh index 8a01629b96..7becda88c2 100755 --- a/scripts/seed/seed.sh +++ b/scripts/seed/seed.sh @@ -22,7 +22,7 @@ fi csi="nhs-notify-${environment}-app" -client_parameter_namespace=${csi} +client_parameter_namespace="/${csi}/clients" clients=$(jq -c '.clients[]?' "${data_file}") @@ -36,7 +36,7 @@ while IFS= read -r client; do echo "Processing client (${client_name} - ${client_id})" echo "Creating client SSM parameter" - put_client_parameter "${client_parameter_namespace}" "${client}" + put_client_parameter "${client_parameter_namespace}/${client_id}" "${client}" echo "Created client SSM parameter" echo echo "Processed client: (${client_name} - ${client_id})" diff --git a/scripts/seed/utils.sh b/scripts/seed/utils.sh index d537bd4c66..74ee24082e 100644 --- a/scripts/seed/utils.sh +++ b/scripts/seed/utils.sh @@ -1,13 +1,11 @@ #!/bin/bash function put_client_parameter() { - local namespace=$1 + local parameter_name=$1 local client=$2 - local client_id=$(jq -r '.id' <<< "${client}") local campaign_ids=$(jq '.campaignIds' <<< "${client}") local features=$(jq '.features' <<< "${client}") - local parameter_name="/${namespace}/clients/${client_id}" local parameter_value=$(jq <<< "{ \"campaignIds\": ${campaign_ids}, \"features\": ${features}