From 135be76a0c68c290f4fe3fe257f46990468d1180 Mon Sep 17 00:00:00 2001 From: jonnyry Date: Wed, 8 Jan 2025 15:23:26 +0000 Subject: [PATCH] Update to deal with scenario where TRE_ID is not available --- devops/scripts/kv_add_network_exception.sh | 18 ++++++++++++++---- devops/scripts/kv_remove_network_exception.sh | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/devops/scripts/kv_add_network_exception.sh b/devops/scripts/kv_add_network_exception.sh index 41bbe9753..90786ab2f 100755 --- a/devops/scripts/kv_add_network_exception.sh +++ b/devops/scripts/kv_add_network_exception.sh @@ -5,15 +5,25 @@ function main() { set -o errexit set -o pipefail - # parse params/set up inputs + # attempt to determine our tre id # - if [[ -z "$TRE_ID" ]]; then + local TRE_ID_LOCAL="${TRE_ID:-}" + + if [[ -z "$TRE_ID_LOCAL" ]]; then + if [[ "${core_tre_rg:-}" == rg-* ]]; then # TRE_ID may not be available when called from destroy_env_no_terraform.sh + TRE_ID_LOCAL="${core_tre_rg#rg-}" + fi + fi + + if [[ -z "$TRE_ID_LOCAL" ]]; then echo -e "Could not add keyvault deployment network exception: TRE_ID is not set\nExiting...\n" exit 1 fi - local RG_NAME="rg-${TRE_ID}" - local KV_NAME="kv-${TRE_ID}" + # set up variables + # + local RG_NAME="rg-${TRE_ID_LOCAL}" + local KV_NAME="kv-${TRE_ID_LOCAL}" local MY_IP="${PUBLIC_DEPLOYMENT_IP_ADDRESS:-}" if [[ -z "$MY_IP" ]]; then diff --git a/devops/scripts/kv_remove_network_exception.sh b/devops/scripts/kv_remove_network_exception.sh index bf048f358..d46e6e1fd 100755 --- a/devops/scripts/kv_remove_network_exception.sh +++ b/devops/scripts/kv_remove_network_exception.sh @@ -5,15 +5,25 @@ function main() { set -o errexit set -o pipefail - # parse params/set up inputs + # attempt to determine our tre id # - if [[ -z "$TRE_ID" ]]; then + local TRE_ID_LOCAL="${TRE_ID:-}" + + if [[ -z "$TRE_ID_LOCAL" ]]; then + if [[ "${core_tre_rg:-}" == rg-* ]]; then # TRE_ID may not be available when called from destroy_env_no_terraform.sh + TRE_ID_LOCAL="${core_tre_rg#rg-}" + fi + fi + + if [[ -z "$TRE_ID_LOCAL" ]]; then echo -e "Could not remove keyvault deployment network exception: TRE_ID is not set\nExiting...\n" exit 1 fi - local RG_NAME="rg-${TRE_ID}" - local KV_NAME="kv-${TRE_ID}" + # set up variables + # + local RG_NAME="rg-${TRE_ID_LOCAL}" + local KV_NAME="kv-${TRE_ID_LOCAL}" local MY_IP="${PUBLIC_DEPLOYMENT_IP_ADDRESS:-}" if [[ -z "$MY_IP" ]]; then