安全规则具有无效的端口范围地形

Security rule has invalid Port range terraform

无法使用 terraform 在 Azure 中为 nsg 安全规则提供 destination_port_range。 Terraform v0.12.28 provider.azurerm v2.18.0

security_rule {
    name                       = "databricks-control-plane-inbound-rule"
    priority                   = 110
    direction                  = "Inbound"
    access                     = "Allow"
    protocol                   = "Tcp"
    source_port_range          = "*"
    destination_port_range     = 225557
  }

Error: Failure sending request: StatusCode=400 -- Original Error:
Code="SecurityRuleInvalidPortRange" Message="Security rule has invalid Port range. Value provided: 225557. Value should be an integer OR integer range with '-' delimiter. Valid range 0-65535." Details=[]

您的 security_rule 中的 destination_port_range225557,这不是一个有效的端口号,因为它多了一位数。它应该是 065535

之间的数字

对于您的问题,您想在一个 NSG 规则中添加多个目标端口。所以你需要像这样使用 destination_port_ranges 而不是 destination_port_range

security_rule {
    name                       = "databricks-control-plane-inbound-rule"
    priority                   = 110
    direction                  = "Inbound"
    access                     = "Allow"
    protocol                   = "Tcp"
    source_port_range          = "*"
    destination_port_ranges    = ["22", "5557"]
  }