作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您能帮我指出正确的方向吗?我无法将前端 IP 配置的名称从负载均衡器资源引用到负载均衡器规则资源。
我已阅读文档并通过导出的 front_ip_configuration
名称在负载均衡器规则中引用前端 IP 配置名称。此外,还尝试仅复制负载均衡器规则资源中的公共(public) IP 名称。
load-balancer.tf
配置文件resource "azurerm_public_ip" "internal_lb_public_ip" {
name = "PublicIPForLB"
location = data.azurerm_resource_group.rg.location
resource_group_name = data.azurerm_resource_group.rg.name
allocation_method = "Static"
sku = "Standard"
}
# internal standard sku load balancer
resource "azurerm_lb" "internal_lb" {
name = "myIntLoadBalancer"
location = data.azurerm_resource_group.rg.location
resource_group_name = data.azurerm_resource_group.rg.name
sku = "Standard"
frontend_ip_configuration {
name = "LoadBalancerFrontEndIP"
public_ip_address_id = azurerm_public_ip.internal_lb_public_ip.id
}
tags = local.common_tags
}
#-------------------------------------------------------------
# backend address pool - defines the group of resources that will serve traffic for a given load-balancing rule.
resource "azurerm_lb_backend_address_pool" "backend_pool" {
loadbalancer_id = azurerm_lb.internal_lb.id
name = "myBackendPool"
}
# addresses of vms placed within backend address pool.
# note: "backend Addresses can only be added to a Standard SKU Load Balancer."
resource "azurerm_lb_backend_address_pool_address" "backend_address" {
count = 3
name = "vmIP${count.index}"
backend_address_pool_id = azurerm_lb_backend_address_pool.backend_pool.id
# private ip address taken from virtual machine network interface asssociated with virtual machine
ip_address = azurerm_network_interface.vm_nic[count.index].private_ip_address
virtual_network_id = azurerm_virtual_network.lbvnet.id
}
#-------------------------------------------------------------
# health probe
resource "azurerm_lb_probe" "lb_http_health_probe" {
loadbalancer_id = azurerm_lb.internal_lb.id
name = "HTTPHealthProbe"
protocol = "Http"
port = 80
# URI, uniform resource identifier, used for requesting health status from the backend endpoint
request_path = "/"
# time gap between health probes
interval_in_seconds = 15
# number of failed probe attempts after which the backend endpoint is removed from rotation
number_of_probes = 2
}
#-------------------------------------------------------------
# laod balancing rule defining how traffic is distributed to the VMs
# azure load balancer resources require the Load Balancer needs to have a FrontEnd IP Configuration Attached
resource "azurerm_lb_rule" "lb_rule" {
loadbalancer_id = azurerm_lb.internal_lb.id
name = "myHTTPRule"
protocol = "Tcp"
frontend_port = 80
backend_port = 80
# name of the frontend IP configuration to which the rule is associated.
frontend_ip_configuration_name = "${azurerm_lb.internal_lb.frontend_ip_configuration[0].id}"
# idle timeout in minutes for TCP connections.
idle_timeout_in_minutes = 15
# reference to a Backend Address Pool over which this Load Balancing Rule operates.
backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.backend_pool.id}"]
# a "floating” IP is reassigned to a secondary server in case the primary server fails
enable_floating_ip = false
# the load balancing distribution type to be used by the Load Balancer
load_distribution = "None"
}
#-------------------------------------------------------------
│ Error: expanding Load Balancer Rule: [ERROR] Cannot find FrontEnd IP Configuration with the name /subscriptions/00000000-00000-00000-0000-0000000000/resourceGroups/-----/providers/Microsoft.Network/loadBalancers/myIntLoadBalancer/frontendIPConfigurations/LoadBalancerFrontEndIP
│
│ with azurerm_lb_rule.lb_rule,│ on load-balancer.tf line 63, in resource "azurerm_lb_rule" "lb_rule":
│ 63: resource "azurerm_lb_rule" "lb_rule" {
最佳答案
用这个代替
frontend_ip_configuration_name = azurerm_lb.internal_lb.frontend_ip_configuration[0].name
关于azure - Terraform - Azure 负载均衡器规则 - 引用前端 IP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74066420/
我是一名优秀的程序员,十分优秀!