mikeknows
mikeknows

Reputation: 115

Security rule has invalid Port range terraform

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=[]

Upvotes: 0

Views: 4511

Answers (2)

Charles Xu
Charles Xu

Reputation: 31424

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"]
  }

Upvotes: 6

berenbums
berenbums

Reputation: 1354

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

Upvotes: 2

Related Questions