[英]How to add a backend with virtual machine IP for Azure Load Balancer in Terraform
I am creating an Azure load balancer that I need to route the incoming traffic to backend pool which consist of a virtual machine.我正在创建一个 Azure 负载均衡器,我需要将传入流量路由到由虚拟机组成的后端池。
I am using Terraform to do this.我正在使用 Terraform 来做到这一点。
So far, I have created the followings:到目前为止,我已经创建了以下内容:
But in the terraform
for backend, there's no way I can setup the IP address of the VM.但是在后端的
terraform
中,我无法设置 VM 的 IP 地址。
Here's my code.这是我的代码。 How can I do this?
我怎样才能做到这一点?
resource "azurerm_lb" "example" {
name = "TestLoadBalancer"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
sku = "Standard"
frontend_ip_configuration {
name = "classiclb"
subnet_id = azurerm_subnet.vm.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_lb_backend_address_pool" "example" {
loadbalancer_id = azurerm_lb.example.id
name = "classiclb"
}
resource "azurerm_lb_probe" "example" {
resource_group_name = azurerm_resource_group.example.name
loadbalancer_id = azurerm_lb.example.id
name = "classiclb"
port = 80
interval_in_seconds = 10
number_of_probes = 3
protocol = "Http"
request_path = "/"
}
resource "azurerm_lb_rule" "example" {
resource_group_name = azurerm_resource_group.example.name
loadbalancer_id = azurerm_lb.example.id
name = "classiclb"
protocol = "Tcp"
frontend_port = 80
backend_port = 80
frontend_ip_configuration_name = "classiclb"
backend_address_pool_id = azurerm_lb_backend_address_pool.example.id
probe_id = azurerm_lb_probe.example.id
}
根据注释,使用azurerm_lb_backend_address_pool_address添加地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.