{"action":"created","issue":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/608","repository_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm","labels_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/608/labels{/name}","comments_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/608/comments","events_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/608/events","html_url":"https://github.com/terraform-providers/terraform-provider-azurerm/issues/608","id":279554437,"number":608,"title":"Fail to destroy subnet in use by gateway ip configuration of application gateway","user":{"login":"genevieve","id":12158641,"avatar_url":"https://avatars2.githubusercontent.com/u/12158641?v=4","gravatar_id":"","url":"https://api.github.com/users/genevieve","html_url":"https://github.com/genevieve","followers_url":"https://api.github.com/users/genevieve/followers","following_url":"https://api.github.com/users/genevieve/following{/other_user}","gists_url":"https://api.github.com/users/genevieve/gists{/gist_id}","starred_url":"https://api.github.com/users/genevieve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/genevieve/subscriptions","organizations_url":"https://api.github.com/users/genevieve/orgs","repos_url":"https://api.github.com/users/genevieve/repos","events_url":"https://api.github.com/users/genevieve/events{/privacy}","received_events_url":"https://api.github.com/users/genevieve/received_events","type":"User","site_admin":false},"labels":[{"id":620326271,"url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/labels/bug","name":"bug","color":"f7c6c7","default":true},{"id":794964054,"url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/labels/service/application-gateway","name":"service/application-gateway","color":"0e8a16","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-12-05T22:28:58Z","updated_at":"2018-03-08T16:25:58Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"### Terraform Version\r\nAzure Provider v0.3.3\r\nTerraform v0.11.0\r\n\r\n### Affected Resource(s)\r\n- azurerm_subnet\r\n- azurerm_application_gateway\r\n\r\n\r\n### Terraform Configuration Files\r\n```hcl\r\nresource \"azurerm_subnet\" \"sub1\" {\r\n  name                 = \"${var.env_id}-cf-subnet1\"\r\n  address_prefix       = \"${cidrsubnet(var.network_cidr, 8, 1)}\"\r\n  resource_group_name  = \"${azurerm_resource_group.bosh.name}\"\r\n  virtual_network_name = \"${azurerm_virtual_network.bosh.name}\"\r\n}\r\n\r\n...\r\n\r\nresource \"azurerm_application_gateway\" \"network\" {\r\n  name                = \"${var.env_id}-app-gateway\"\r\n  resource_group_name = \"${azurerm_resource_group.bosh.name}\"\r\n  location            = \"West US\"\r\n\r\n  sku {\r\n    name     = \"Standard_Small\"\r\n    tier     = \"Standard\"\r\n    capacity = 2\r\n  }\r\n\r\n  probe {\r\n    name                = \"Probe01\"\r\n    protocol            = \"Http\"\r\n    path                = \"/login\"\r\n    host                = \"login.${var.system_domain}\"\r\n    interval            = 60\r\n    timeout             = 60\r\n    unhealthy_threshold = 3\r\n  }\r\n\r\n  gateway_ip_configuration {\r\n    name      = \"${var.env_id}-cf-gateway-ip-configuration\"\r\n    subnet_id = \"${azurerm_virtual_network.bosh.id}/subnets/${azurerm_subnet.sub1.name}\"\r\n  }\r\n\r\n  frontend_port {\r\n    name = \"frontendporthttps\"\r\n    port = 443\r\n  }\r\n\r\n  frontend_port {\r\n    name = \"frontendportlogs\"\r\n    port = 4443\r\n  }\r\n\r\n  frontend_ip_configuration {\r\n    name                 = \"${var.env_id}-cf-frontend-ip-configuration\"\r\n    public_ip_address_id = \"${azurerm_public_ip.lb.id}\"\r\n  }\r\n\r\n  backend_address_pool {\r\n    name = \"${var.env_id}-cf-backend-address-pool\"\r\n  }\r\n\r\n  backend_http_settings {\r\n    name                  = \"${azurerm_virtual_network.bosh.name}-be-htst\"\r\n    cookie_based_affinity = \"Disabled\"\r\n    port                  = 80\r\n    protocol              = \"Http\"\r\n    request_timeout       = 1\r\n    probe_name            = \"Probe01\"\r\n  }\r\n\r\n  ssl_certificate {\r\n    name     = \"ssl-cert\"\r\n    data     = \"${var.pfx_cert_base64}\"\r\n    password = \"${var.pfx_password}\"\r\n  }\r\n\r\n  http_listener {\r\n    name                           = \"${azurerm_virtual_network.bosh.name}-httplstn\"\r\n    frontend_ip_configuration_name = \"${var.env_id}-cf-frontend-ip-configuration\"\r\n    frontend_port_name             = \"frontendporthttps\"\r\n    protocol                       = \"Https\"\r\n    ssl_certificate_name           = \"ssl-cert\"\r\n  }\r\n\r\n  request_routing_rule {\r\n    name                       = \"${azurerm_virtual_network.bosh.name}-rqrt\"\r\n    rule_type                  = \"Basic\"\r\n    http_listener_name         = \"${azurerm_virtual_network.bosh.name}-httplstn\"\r\n    backend_address_pool_name  = \"${var.env_id}-cf-backend-address-pool\"\r\n    backend_http_settings_name = \"${azurerm_virtual_network.bosh.name}-be-htst\"\r\n  }\r\n}\r\n\r\n\r\n```\r\n\r\n### Debug Output\r\n```\r\nError: Error applying plan:\r\n\r\n1 error(s) occurred:\r\n\r\n* azurerm_subnet.cf-lb (destroy): 1 error(s) occurred:\r\n\r\n* azurerm_subnet.cf-lb: network.SubnetsClient#Delete: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code=\"InUseSubnetCannotBeDeleted\" Message=\"Subnet bbl-env-cf-sn is in use by /subscriptions/XXXX/resourceGroups/XXXX/providers/Microsoft.Network/applicationGateways/bbl-env-app-gateway/gatewayIPConfigurations/bbl-env-cf-gateway-ip-configuration and cannot be deleted.\" Details=[]\r\n```\r\n\r\n### Expected Behavior\r\n`terraform destroy` should have successfully destroyed.\r\n\r\n### Actual Behavior\r\nIt failed to destroy the subnet as it is in use by the gateway ip configuration that references the subnet in the configuration of the application gateway.\r\n\r\nAfter a second `terraform destroy`, it successfully destroyed the subnet.\r\n\r\n### Steps to Reproduce\r\n1. `terraform apply`\r\n2. `terraform destroy`\r\n"},"comment":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/comments/371540068","html_url":"https://github.com/terraform-providers/terraform-provider-azurerm/issues/608#issuecomment-371540068","issue_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/608","id":371540068,"user":{"login":"tombuildsstuff","id":666005,"avatar_url":"https://avatars1.githubusercontent.com/u/666005?v=4","gravatar_id":"","url":"https://api.github.com/users/tombuildsstuff","html_url":"https://github.com/tombuildsstuff","followers_url":"https://api.github.com/users/tombuildsstuff/followers","following_url":"https://api.github.com/users/tombuildsstuff/following{/other_user}","gists_url":"https://api.github.com/users/tombuildsstuff/gists{/gist_id}","starred_url":"https://api.github.com/users/tombuildsstuff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tombuildsstuff/subscriptions","organizations_url":"https://api.github.com/users/tombuildsstuff/orgs","repos_url":"https://api.github.com/users/tombuildsstuff/repos","events_url":"https://api.github.com/users/tombuildsstuff/events{/privacy}","received_events_url":"https://api.github.com/users/tombuildsstuff/received_events","type":"User","site_admin":false},"created_at":"2018-03-08T16:25:58Z","updated_at":"2018-03-08T16:25:58Z","author_association":"CONTRIBUTOR","body":"@genevieve sorry, missed this notification - let's leave this issue open until the other issues resolved, since others may find it when searching. FWIW I'm chasing the API issue through our internal channels too."}}
{"actor":{"display_login":"tombuildsstuff"}}