Security rule has invalid Port range terraform

回眸只為那壹抹淺笑 提交于 2021-02-11 14:21:46

问题


Unable to provide destination_port_range for nsg security rule in azure using terraform. 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=[]


回答1:


For your issue, you want to add multiple destination ports in one NSG rule. So you need to use the destination_port_ranges instead of the destination_port_range like this:

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



回答2:


The destination_port_range in your security_rule is 225557, which is not a valid port number because it has one digit too many. It should be a number between 0 and 65535



来源:https://stackoverflow.com/questions/63016875/security-rule-has-invalid-port-range-terraform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!