Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform crashed- for azure_application_gateway while using dynamic for inside properties #6043

Closed
ghost opened this issue Mar 9, 2020 · 1 comment · Fixed by #7789
Closed

Comments

@ghost
Copy link

ghost commented Mar 9, 2020

This issue was originally opened by @samitkumarpatel as hashicorp/terraform#24315. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.12.14
+ provider.azurerm v2.0.0

Terraform Configuration Files

resource "azurerm_public_ip" "network" {
  name                = "pip01"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  allocation_method   = "Dynamic"
}

variable "gateway_config" {
  type = list
  default = [
    {
      gwPublicIpName            = "nginxPublicIp"
      gwFrontendHttpPortName    = "nginxFEPort80"
      gwFrontendIpName          = "nginxFEIpip"
      gwBackendPoolName         = "nginxBEPool"
      gwBackendHttpPortName     = "nginxBEhttpPort80"
      gatewayListnerName        = "nginxListner"
      gatewayRuleName           = "nginxRule"
    },
    {
      gwPublicIpName            = "jeninsPublicIp"
      gwFrontendHttpPortName    = "jenkinsFEPort8080"
      gwFrontendIpName          = "jenkinsFEIpip"
      gwBackendPoolName         = "jenkinsBEPool"
      gwBackendHttpPortName     = "jenkinsBEhttpPort8080"
      gatewayListnerName        = "jenkinsListner"
      gatewayRuleName           = "jenkinsRule"
    }
  ]
}

resource "azurerm_application_gateway" "example" {
  name                = "ag01"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location

  sku {
    name     = "Standard_Small"
    tier     = "Standard"
    capacity = 2
  }
  
  dynamic "gateway_ip_configuration" {
    for_each = [for s in var.gateway_config: {
        name      = s.gwPublicIpName
        subnet_id = element(tolist(azurerm_virtual_network.example.subnet),0).id
    }]

    content {
      name          = gateway_ip_configuration.value.name
      subnet_id     = gateway_ip_configuration.value.subnet_id
    }
  }
  
  dynamic "frontend_port" {
      for_each  =  [ for s in var.gateway_config: {
        name = s.gwFrontendHttpPortName
        port = 80
      }]
      content {
        name = frontend_port.value.name
        port = frontend_port.value.port
      }
  }
  
  dynamic "frontend_ip_configuration" {
      for_each  =  [ for s in var.gateway_config: {
        name                 = s.gwFrontendIpName
        public_ip_address_id = azurerm_public_ip.network.id
      }]
      content {
        name                 = frontend_ip_configuration.value.name
        public_ip_address_id = frontend_ip_configuration.value.public_ip_address_id
      }
  }
  
  dynamic "backend_address_pool" {
      for_each  =  [ for s in var.gateway_config: {
        name          = s.gwBackendPoolName
        #ip_addresses = []
      }]
      content {
        name          = backend_address_pool.value.name
        #ip_addresses = backend_address_pool.value.ip_addresses
      }
  }

  dynamic "backend_http_settings" {
      for_each  =  [ for s in var.gateway_config: {
        name                  = s.gwBackendHttpPortName
        cookie_based_affinity = "Disabled"
        port                  = 80
        protocol              = "Http"
        request_timeout       = 1
      }]
      content {
        name                  = backend_http_settings.value.name
        cookie_based_affinity = backend_http_settings.value.cookie_based_affinity
        port                  = backend_http_settings.value.port
        protocol              = backend_http_settings.value.protocol
        request_timeout       = backend_http_settings.value.request_timeout
      }
  }

  dynamic "http_listener" {
      for_each  =  [ for s in var.gateway_config: {
        name                           = s.gatewayListnerName
        frontend_ip_configuration_name = s.gwFrontendIpName
        frontend_port_name             = s.gwFrontendHttpPortName
        protocol                       = "Http"
      }]
      content {
        name                           = http_listener.value.name
        frontend_ip_configuration_name = http_listener.value.frontend_ip_configuration_name
        frontend_port_name             = http_listener.value.frontend_port_name
        protocol                       = http_listener.value.protocol
      }
  }

  dynamic "request_routing_rule" {
      for_each  =  [ for s in var.gateway_config: {
        name                       = s.gatewayRuleName
        rule_type                  = "Basic"
        http_listener_name         = s.gatewayListnerName
        backend_address_pool_name  = s.gwBackendPoolName
        backend_http_settings_name = s.gwBackendHttpPortName
      }]
      content {
        name                       = request_routing_rule.value.name
        rule_type                  = request_routing_rule.value.rule_type
        http_listener_name         = request_routing_rule.value.http_listener_name
        backend_address_pool_name  = request_routing_rule.value.backend_address_pool_name
        backend_http_settings_name = request_routing_rule.value.backend_http_settings_name
      }
  }
  
  tags  =   azurerm_resource_group.example.tags
}

Debug Output

Crash Output

attached
crash.log

Expected Behavior

Should create the application gateway with configuration

Actual Behavior

ERROR

Steps to Reproduce

Just run the hcl sysntex

@ghost
Copy link
Author

ghost commented Aug 17, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Aug 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
1 participant