繁体   English   中英

Terraform-Azure-无法为应用程序网关 StandardV2 创建私有 IP 配置

[英]Terraform-Azure-Unable to create Private IP configuration for application Gateway StandardV2

I'm trying to create an application gateway (Standard V2) with both public IP and private IP configuration, but upon creation only public IP is being created and private IP configuration is nowhere to be found. 我的 terraform 代码根本看不到任何错误。 我不确定我在哪里丢失了东西。下面是我的 terraform 代码。

provider "azurerm" {
  version = "=1.44"
}
provider "null" {
  version = "=2.1"
}

resource "azurerm_public_ip" "appgwip" {
  name                = "appgwtestpip"
  location            = "Southeast Asia"
  resource_group_name = "myrgname"
  allocation_method   = "Static"
  sku  = "Standard"
}

resource "azurerm_application_gateway" "appgw" {
    depends_on  = [azurerm_public_ip.appgwip]
    name = "testappgw-sea"
    resource_group_name = "myrgname"
    location  = "Southeast Asia"
    sku {
        name = "Standard_v2"
        tier = "Standard_v2"
        capacity = 2
    }
    gateway_ip_configuration {
        name = "APPGW-IPCONFIG-test"
        subnet_id = "mysubnetid"
    }
    frontend_port {
        name = "Httpport"
        port = 80
    }
    frontend_ip_configuration {
        name = "AppgwPIPConfig"
        public_ip_address_id = azurerm_public_ip.appgwip.id
        private_ip_address   = "An IP address within the subnet range"
        private_ip_address_allocation  = "Static"
    }
    backend_address_pool {
        name = "test-bp"
 {
         name = "test-listener-80"
         frontend_ip_configuration_name = "AppgwPIPConfig"
         frontend_port_name = "Httpport"
         protocol = "Http"
     }
     request_routing_rule {
         name = "test-rule01"
         rule_type = "Basic"
         http_listener_name = "test-listener-80"
         backend_address_pool_name = "test-bp"
         backend_http_settings_name = "test-http"
     }

}

您应该定义两个frontend_ip_configuration块,一个用于公共 IP 配置,另一个用于私有 IP 配置。

这是一个工作示例供您参考。

 # since these variables are re-used - a locals block makes this more maintainable
locals {
  backend_address_pool_name      = "${azurerm_virtual_network.test.name}-beap"
  frontend_port_name             = "${azurerm_virtual_network.test.name}-feport"
  frontend_ip_configuration_name = "${azurerm_virtual_network.test.name}-feip"
  http_setting_name              = "${azurerm_virtual_network.test.name}-be-htst"
  listener_name                  = "${azurerm_virtual_network.test.name}-httplstn"
  request_routing_rule_name      = "${azurerm_virtual_network.test.name}-rqrt"
  redirect_configuration_name    = "${azurerm_virtual_network.test.name}-rdrcfg"
}




resource "azurerm_application_gateway" "network" {
  name                = "example-appgateway"
  resource_group_name = "${azurerm_resource_group.test.name}"
  location            = "${azurerm_resource_group.test.location}"

  sku {
    name     = "WAF_v2"
    tier     = "WAF_v2"
    capacity = 2
  }

  gateway_ip_configuration {
    name      = "my-gateway-ip-configuration"
    subnet_id = "${azurerm_subnet.frontend.id}"
  }


  frontend_port {
    name = "${local.frontend_port_name}"
    port = 80
  }

  frontend_ip_configuration {
    name                 = "${local.frontend_ip_configuration_name}"
    public_ip_address_id = "${azurerm_public_ip.test.id}"
  }


 frontend_ip_configuration {
    name                 = "${local.frontend_ip_configuration_name}-private"
    subnet_id = "${azurerm_subnet.frontend.id}"
    private_ip_address_allocation = "Static"
    private_ip_address = "10.254.0.10"
  }



  backend_address_pool {
    name = "${local.backend_address_pool_name}"
  }

  backend_http_settings {
    name                  = "${local.http_setting_name}"
    cookie_based_affinity = "Disabled"
    path                  = "/path1/"
    port                  = 80
    protocol              = "Http"
    request_timeout       = 1
  }

  http_listener {
    name                           = "${local.listener_name}"
    frontend_ip_configuration_name = "${local.frontend_ip_configuration_name}"
    frontend_port_name             = "${local.frontend_port_name}"
    protocol                       = "Http"
  }

  request_routing_rule {
    name                       = "${local.request_routing_rule_name}"
    rule_type                  = "Basic"
    http_listener_name         = "${local.listener_name}"
    backend_address_pool_name  = "${local.backend_address_pool_name}"
    backend_http_settings_name = "${local.http_setting_name}"
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM