Application gateway listner was not found during terraform deployment

Thirumal Rao D 1 Reputation point
2023-07-06T03:50:21.27+00:00

Below is the terraform code which I am using to deploy WAF-2 appGW and provided all the required code for the certificate and all even though it's getting error .

this is the error:

Error: creating Application Gateway: (Name "appgw-appgw-v2-eastus" / Resource Group "rg-test-01"): network.ApplicationGatewaysClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidResourceReference" Message="Resource /subscriptions/7674bdf6-953a-4f69-b581-219e134c9a73/resourceGroups/rg-test-01/providers/Microsoft.Network/applicationGateways/appgw-appgw-v2-eastus/sslCertificates/ssl_cert_name referenced by resource /subscriptions/7674bdf6-953a-4f69-b581-219e134c9a73/resourceGroups/rg-test-01/providers/Microsoft.Network/applicationGateways/appgw-appgw-v2-eastus/httpListeners/listenertest was not found. Please make sure that the referenced resource exists, and that both resources are in the same region." Details=[]

  dynamic "frontend_port" {
    for_each = var.frontend_port_config
    content {
      name = frontend_port.value.name
      port = frontend_port.value.port
    }
  }
  ssl_policy {
    policy_name          = var.ssl_policy["policy_type"] == "Predifined" ? var.ssl_policy["Policy_name"] : null
    policy_type          = var.ssl_policy["policy_type"]
    cipher_suites        = var.ssl_policy["policy_type"] == "Custom" ? var.ssl_policy["cipher_suites"] : null
    min_protocol_version = var.ssl_policy["policy_type"] == "Custom" ? "TLSv1_2" : null
  }
  dynamic "ssl_certificate" {
    for_each = var.ssl_certificate_config
    content {
      name                = ssl_certificate.value.ssl_certificate_name
      #data                = ssl_certificate.value.secret_id ? null : "${filebase64(ssl_certificate.value.ssl.ssl_cert_path)}"
      #data = "${base64encode(file("/Users/thirumaldage/Desktop/cert.crt"))}"
      #key_vault_secret_id = ssl_certificate.key_vault_secret_id ? data.azurerm_key_valut_certificate.certificate[ssl_certificate.key].secret_id : null
      key_vault_secret_id = data.azurerm_key_vault_certificate.certificate.secret_id
    }
  }
 identity {
    type         = "UserAssigned"
    #identity_ids = [azurerm_user_assigned_identity.identity.id]
    identity_ids = [data.azurerm_user_assigned_identity.identity.id]
  }
  dynamic "http_listener" {
    for_each = var.http_routing_config
    content {
      name                           = http_listener.value.http_listener_name
      host_name                      = http_listener.value.http_listener_host_name
      frontend_ip_configuration_name = local.private_frontend_ip_configuration_name
      frontend_port_name             = http_listener.value.frontend_port_name
      protocol                       = "Https"
      ssl_certificate_name           = http_listener.value.ssl_certificate_name
      require_sni                    = true
    }
  }
  dynamic "request_routing_rule" {
    for_each = var.http_routing_config
    content {
      name                       = request_routing_rule.key
      rule_type                  = "Basic"
      http_listener_name         = request_routing_rule.value.http_listener_name
      backend_address_pool_name  = request_routing_rule.value.backend_address_pool_name
      priority                   = request_routing_rule.value.priority
      backend_http_settings_name = "${request_routing_rule.key}-backend-setting"
      rewrite_rule_set_name      = request_routing_rule.value.rewrite_rule_set_name
    }
  }
  dynamic "trusted_root_certificate" {
    for_each = var.trusted_root_certificate
    content {
      name = trusted_root_certificate.key
      data = base64encode(file("${trusted_root_certificate.value}"))
    }
  }
Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,216 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Thirumal Rao D 1 Reputation point
    2023-07-07T17:38:48.5033333+00:00

    GOT IT....

    As I have given the name of backend_http_setting_name = demo-http-settings and giving it as demo-http-setting in request_routing_rule. It will error out as it can't find the backend http setting.

    Thank you!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.