From 42fc77e8f6c189cc5d46a440c367c349623a6a02 Mon Sep 17 00:00:00 2001 From: JatinderSingh Date: Tue, 19 Aug 2025 16:09:25 -0700 Subject: [PATCH] destroy test env --- .github/workflows/.deployer.yml | 4 ++-- .github/workflows/destroy-test.yml | 28 +++++++++++++++------------- infra/main.tf | 2 +- infra/modules/network/main.tf | 2 ++ infra/modules/network/outputs.tf | 3 +++ terragrunt/test/terragrunt.hcl | 3 +++ 6 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 terragrunt/test/terragrunt.hcl diff --git a/.github/workflows/.deployer.yml b/.github/workflows/.deployer.yml index 0cc100a..c2c05bd 100644 --- a/.github/workflows/.deployer.yml +++ b/.github/workflows/.deployer.yml @@ -84,6 +84,6 @@ jobs: storage_account_name: ${{ vars.TFSTATE_STORAGE_ACCOUNT }} vnet_address_space: ${{ vars.VNET_ADDRESS_SPACE }} run: | - # Run terraform - terragrunt run-all ${{inputs.command}} --terragrunt-non-interactive + # Run terraform with lock=false to avoid state lock issues + terragrunt run-all ${{inputs.command}} --terragrunt-non-interactive -lock=false \ No newline at end of file diff --git a/.github/workflows/destroy-test.yml b/.github/workflows/destroy-test.yml index 44ea825..1b67e3a 100644 --- a/.github/workflows/destroy-test.yml +++ b/.github/workflows/destroy-test.yml @@ -1,16 +1,18 @@ -name: Destroy Test Environment + name: Destroy Test Environment -permissions: - contents: read + permissions: + contents: write + id-token: write -on: - workflow_dispatch: + on: + workflow_dispatch: -jobs: - destroy-test: - uses: ./.github/workflows/.deployer.yml - with: - environment_name: test - command: destroy - stack_prefix: test-stack # Change this to your actual stack prefix if needed - secrets: inherit + jobs: + destroy-test: + uses: ./.github/workflows/.deployer.yml + with: + environment_name: test + command: destroy + stack_prefix: test-stack # Change this to your actual stack prefix if needed + secrets: inherit + \ No newline at end of file diff --git a/infra/main.tf b/infra/main.tf index 2c87f64..66c9630 100644 --- a/infra/main.tf +++ b/infra/main.tf @@ -79,7 +79,7 @@ module "api" { # Networking private_endpoint_subnet_id = var.app_env == "dev" ? var.dev_app_service_subnet_id : module.network.private_endpoint_subnet_id - app_service_subnet_id = var.app_env == "dev" ? var.dev_app_service_subnet_id : module.network.private_endpoint_subnet_id + app_service_subnet_id = var.app_env == "dev" ? var.dev_app_service_subnet_id : module.network.app_service_subnet_id # App Service app_service_sku_name_api = var.app_service_sku_name_api diff --git a/infra/modules/network/main.tf b/infra/modules/network/main.tf index 10977fe..338a380 100644 --- a/infra/modules/network/main.tf +++ b/infra/modules/network/main.tf @@ -120,6 +120,7 @@ resource "azapi_resource" "privateendpoints_subnet" { addressPrefix = local.private_endpoints_subnet_cidr networkSecurityGroup = { id = azurerm_network_security_group.privateendpoints[0].id + #id = azurerm_network_security_group.privateendpoints.id } } } @@ -137,6 +138,7 @@ resource "azapi_resource" "app_service_subnet" { addressPrefix = local.app_service_subnet_cidr networkSecurityGroup = { id = azurerm_network_security_group.app_service[0].id + #id = azurerm_network_security_group.app_service.id } delegations = [ { diff --git a/infra/modules/network/outputs.tf b/infra/modules/network/outputs.tf index d17d8d0..2c5f9ff 100644 --- a/infra/modules/network/outputs.tf +++ b/infra/modules/network/outputs.tf @@ -2,11 +2,14 @@ output "app_service_subnet_id" { description = "The subnet ID for the App Service." value = var.deploy_network && var.app_env != "dev" ? azapi_resource.app_service_subnet[0].id : null + #value = azapi_resource.app_service_subnet.id + } output "private_endpoint_subnet_id" { description = "The subnet ID for private endpoints." value = var.deploy_network && var.app_env != "dev" ? azapi_resource.privateendpoints_subnet[0].id : null + #value = azapi_resource.privateendpoints_subnet.id } output "dns_servers" { diff --git a/terragrunt/test/terragrunt.hcl b/terragrunt/test/terragrunt.hcl new file mode 100644 index 0000000..3e1f65a --- /dev/null +++ b/terragrunt/test/terragrunt.hcl @@ -0,0 +1,3 @@ +include { + path = find_in_parent_folders() +}