From d607bea6124f2d721ca8ba4bed26c29141b210b6 Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Tue, 2 Jul 2024 16:00:10 +0100 Subject: [PATCH 1/2] Update destroy.sh (#80) --- .../instance/container_apps_bind_dns/scripts/destroy.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/terraform/instance/container_apps_bind_dns/scripts/destroy.sh b/terraform/instance/container_apps_bind_dns/scripts/destroy.sh index acd4b82..1c3d6ac 100644 --- a/terraform/instance/container_apps_bind_dns/scripts/destroy.sh +++ b/terraform/instance/container_apps_bind_dns/scripts/destroy.sh @@ -26,14 +26,13 @@ echo "removed the custom domain from the container app" # wait for the custom domain to be removed tries=0 until [ "$tries" -ge 12 ]; do - DOES_CUSTOM_DOMAIN_EXIST=$( + [[ -z $( az containerapp hostname list \ -n $CONTAINER_APP_NAME \ -g $CONTAINER_APP_RESOURCE_GROUP \ --query "[?name=='$CUSTOM_DOMAIN'].name" \ --output tsv - ) - [[ -z "${$DOES_CUSTOM_DOMAIN_EXIST}" ]] && break + ) ]] && break tries=$((tries + 1)) sleep 10 From 05e59ea549b09d00f403378e7e00a918ba784b2f Mon Sep 17 00:00:00 2001 From: Benjamin Chiverton Date: Tue, 2 Jul 2024 16:14:05 +0100 Subject: [PATCH 2/2] ... --- .github/workflows/instance-destroy-test.yml | 6 +++--- .../scripts/destroy.sh | 20 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/instance-destroy-test.yml b/.github/workflows/instance-destroy-test.yml index d1539f8..178fd80 100644 --- a/.github/workflows/instance-destroy-test.yml +++ b/.github/workflows/instance-destroy-test.yml @@ -36,6 +36,6 @@ jobs: env: TF_VAR_acr_username: "not-used" TF_VAR_acr_password: "not-used" - TF_VAR_website_dns_subdomain: "not-used" - TF_VAR_api_dns_subdomain: "not-used" - TF_VAR_monitoring_dns_subdomain: "not-used" + TF_VAR_website_dns_subdomain: ${{ github.head_ref }}-website + TF_VAR_api_dns_subdomain: ${{ github.head_ref }}-api + TF_VAR_monitoring_dns_subdomain: ${{ github.head_ref }}-monitoring diff --git a/terraform/instance/container_apps_bind_dns/scripts/destroy.sh b/terraform/instance/container_apps_bind_dns/scripts/destroy.sh index 1c3d6ac..3d580bf 100644 --- a/terraform/instance/container_apps_bind_dns/scripts/destroy.sh +++ b/terraform/instance/container_apps_bind_dns/scripts/destroy.sh @@ -7,16 +7,6 @@ die() { exit 111 } -# get the managed cert using the custom domain -CERTIFICATE_ID=$( - az containerapp env certificate list \ - -g $CONTAINER_APP_ENV_RESOURCE_GROUP \ - -n $CONTAINER_APP_ENV_NAME \ - --managed-certificates-only \ - --query "[?properties.subjectName=='$CUSTOM_DOMAIN'].id" \ - --output tsv -) - # remove the custom domain from the container app az containerapp hostname delete --hostname $CUSTOM_DOMAIN \ -g $CONTAINER_APP_RESOURCE_GROUP \ @@ -41,6 +31,16 @@ if [ "$tries" -ge 12 ]; then die "waited for 2 minutes, checked the containerapp 12 times and it still has the custom domain. check azure portal..." fi +# get the managed cert using the custom domain +CERTIFICATE_ID=$( + az containerapp env certificate list \ + -g $CONTAINER_APP_ENV_RESOURCE_GROUP \ + -n $CONTAINER_APP_ENV_NAME \ + --managed-certificates-only \ + --query "[?properties.subjectName=='$CUSTOM_DOMAIN'].id" \ + --output tsv +) + # destroy the cert az containerapp env certificate delete \ -g $CONTAINER_APP_ENV_RESOURCE_GROUP \