From 4da08fa6761d97a79b135238c7bed28d24ded0b7 Mon Sep 17 00:00:00 2001 From: Dominic Robinson Date: Fri, 3 May 2024 17:18:27 +0100 Subject: [PATCH] updated helper scripts --- .../environments/nomis/scripts/all-secrets.sh | 14 +++-- .../environments/nomis/scripts/all-ssm.sh | 14 +++-- .../environments/nomis/scripts/all-tfstate.sh | 54 +++++++++++++++++++ 3 files changed, 72 insertions(+), 10 deletions(-) create mode 100755 terraform/environments/nomis/scripts/all-tfstate.sh diff --git a/terraform/environments/nomis/scripts/all-secrets.sh b/terraform/environments/nomis/scripts/all-secrets.sh index 0d3b79d7609..4c04f82d62a 100755 --- a/terraform/environments/nomis/scripts/all-secrets.sh +++ b/terraform/environments/nomis/scripts/all-secrets.sh @@ -25,14 +25,18 @@ profiles="corporate-staff-rostering-development nomis-data-hub-test nomis-data-hub-preproduction nomis-data-hub-production - planetfm-development - planetfm-test - planetfm-preproduction - planetfm-production oasys-development oasys-test oasys-preproduction - oasys-production" + oasys-production + oasys-national-reporting-development + oasys-national-reporting-test + oasys-national-reporting-preproduction + oasys-national-reporting-production + planetfm-development + planetfm-test + planetfm-preproduction + planetfm-production" action=$1 diff --git a/terraform/environments/nomis/scripts/all-ssm.sh b/terraform/environments/nomis/scripts/all-ssm.sh index 324858a98c5..90fe99edbde 100755 --- a/terraform/environments/nomis/scripts/all-ssm.sh +++ b/terraform/environments/nomis/scripts/all-ssm.sh @@ -25,14 +25,18 @@ profiles="corporate-staff-rostering-development nomis-data-hub-test nomis-data-hub-preproduction nomis-data-hub-production - planetfm-development - planetfm-test - planetfm-preproduction - planetfm-production oasys-development oasys-test oasys-preproduction - oasys-production" + oasys-production + oasys-national-reporting-development + oasys-national-reporting-test + oasys-national-reporting-preproduction + oasys-national-reporting-production + planetfm-development + planetfm-test + planetfm-preproduction + planetfm-production" action=$1 diff --git a/terraform/environments/nomis/scripts/all-tfstate.sh b/terraform/environments/nomis/scripts/all-tfstate.sh new file mode 100755 index 00000000000..5990251f9ee --- /dev/null +++ b/terraform/environments/nomis/scripts/all-tfstate.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# wrapper script to perform ssm operations across all accounts + +profiles="corporate-staff-rostering-development + corporate-staff-rostering-test + corporate-staff-rostering-preproduction + corporate-staff-rostering-production + hmpps-domain-services-development + hmpps-domain-services-test + hmpps-domain-services-preproduction + hmpps-domain-services-production + hmpps-oem-development + hmpps-oem-test + hmpps-oem-preproduction + hmpps-oem-production + nomis-development + nomis-test + nomis-preproduction + nomis-production + nomis-combined-reporting-development + nomis-combined-reporting-test + nomis-combined-reporting-preproduction + nomis-combined-reporting-production + nomis-data-hub-development + nomis-data-hub-test + nomis-data-hub-preproduction + nomis-data-hub-production + oasys-development + oasys-test + oasys-preproduction + oasys-production + oasys-national-reporting-development + oasys-national-reporting-test + oasys-national-reporting-preproduction + oasys-national-reporting-production + planetfm-development + planetfm-test + planetfm-preproduction + planetfm-production" + +for profile in $profiles; do + [[ ${profile} =~ ^#.* ]] && continue + account=$(echo $profile | rev | cut -d- -f2- | rev) + + if [[ -e tfstate/$profile/terraform.tfstate ]]; then + echo $profile: skipping as already downloaded + else + if [[ ! -d tfstate/$profile ]]; then + mkdir -p tfstate/$profile + fi + echo aws s3api get-object --bucket modernisation-platform-terraform-state --key environments/members/$account/$profile/terraform.tfstate tfstate/$profile/terraform.tfstate --profile $profile + aws s3api get-object --bucket modernisation-platform-terraform-state --key environments/members/$account/$profile/terraform.tfstate tfstate/$profile/terraform.tfstate --profile $profile + fi +done