From 02da99452775034c93b64c57ad86b2d64eee29a9 Mon Sep 17 00:00:00 2001 From: Sammy Steiner Date: Wed, 17 Jan 2024 16:34:54 -0500 Subject: [PATCH] move template only logic to the template only bin --- infra/app/service/main.tf | 2 +- template-only-bin/destroy-app-service.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/infra/app/service/main.tf b/infra/app/service/main.tf index db3a5a6e1..98760d80c 100644 --- a/infra/app/service/main.tf +++ b/infra/app/service/main.tf @@ -35,7 +35,7 @@ locals { service_name = "${local.prefix}${module.app_config.app_name}-${var.environment_name}" - is_temporary = startswith(terraform.workspace, "t-") || startswith(module.project_config.project_name, "plt-tst-act-") + is_temporary = startswith(terraform.workspace, "t-") # Include project name in bucket name since buckets need to be globally unique across AWS bucket_name = "${local.prefix}${module.project_config.project_name}-${module.app_config.app_name}-${var.environment_name}" diff --git a/template-only-bin/destroy-app-service.sh b/template-only-bin/destroy-app-service.sh index b0122c6aa..d5dd6b58a 100755 --- a/template-only-bin/destroy-app-service.sh +++ b/template-only-bin/destroy-app-service.sh @@ -7,11 +7,12 @@ BACKEND_CONFIG_FILE="dev.s3.tfbackend" sed -i.bak 's/force_destroy = false/force_destroy = true/g' infra/modules/service/access-logs.tf sed -i.bak 's/force_destroy = false/force_destroy = true/g' infra/modules/storage/main.tf +sed -i.bak 's/enable_deletion_protection = var.is_temp_environment/enable_deletion_protection = false/g' infra/modules/service/load-balancer.tf cd infra/app/service terraform init -reconfigure -backend-config=$BACKEND_CONFIG_FILE -terraform apply -auto-approve -target="module.service.aws_s3_bucket.access_logs" -var="environment_name=dev" +terraform apply -auto-approve -target="module.service.aws_s3_bucket.access_logs" -target="module.service.aws_lb.alb" -var="environment_name=dev" terraform destroy -auto-approve -var="environment_name=dev"