不确定我在做什么错。我在terraform配置中只有一个NAT规则,并且没有使用NAT池。
错误:
azurerm_virtual_machine_scale_set.development-eastus-ss: compute.VirtualMachineScaleSetsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidRequestFormat" Message="Cannot parse the request." Details=[{"code":"InvalidJsonReferenceWrongType","message":"Reference Id /subscriptions/sub-id/resourceGroups/prod-eastus-rg/providers/Microsoft.Network/loadBalancers/development-eastus-lb/inboundNatRules/development-eastus-lb-nat-http is referencing resource of a wrong type. The Id is expected to reference resources of type loadBalancers/inboundNatPools. Path Properties.UpdateGroups[0].NetworkProfile.networkInterfaceConfigurations[0].properties.ipConfigurations[0].properties.loadBalancerInboundNatPools[0]."}]
NAT规则:
resource "azurerm_lb_nat_rule" "development-eastus-lb-nat-http" {
name = "development-eastus-lb-nat-http"
resource_group_name = "${var.resource_group_name}"
loadbalancer_id = "${azurerm_lb.development-eastus-lb.id}"
protocol = "Tcp"
frontend_port = 80
backend_port = 8080
frontend_ip_configuration_name = "development-eastus-lb-frontend"
答案 0 :(得分:1)
看起来这是尝试将单个nat规则绑定到比例集的问题。正如错误所暗示的那样,它期望一个nat pool而不是nat rule一个nat池将允许负载均衡器和比例集建立一组规则,其中负载均衡器将为每个负载提供不同的端口。基础虚拟机到虚拟机上的同一端口。
考虑要在RDP上远程访问特定VM的方法,这可以通过为您提供一个唯一的端口来使用,以映射到该VM来实现。
resource "azurerm_lb_nat_pool" "test" {
resource_group_name = "${azurerm_resource_group.test.name}"
loadbalancer_id = "${azurerm_lb.test.id}"
name = "SampleApplicationPool"
protocol = "Tcp"
frontend_port_start = 80
frontend_port_end = 81
backend_port = 8080
frontend_ip_configuration_name = "PublicIPAddress"
}
但是,如果您希望内部运行一个服务(例如HTTP网站)而不是外部运行一个端口(例如本地网络上的8080,然后在外部公共网络上运行端口80),那么我来看看lb rule,因为它特别允许您设置端口,如下所示。
resource "azurerm_lb_rule" "test" {
resource_group_name = "${azurerm_resource_group.test.name}"
loadbalancer_id = "${azurerm_lb.test.id}"
name = "LBRule"
protocol = "Tcp"
frontend_port = 3389
backend_port = 3389
frontend_ip_configuration_name = "PublicIPAddress"
}
希望这会有所帮助