Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple remote_port issue #220

Open
1 task done
codeuday95 opened this issue Jan 18, 2023 · 4 comments
Open
1 task done

Multiple remote_port issue #220

codeuday95 opened this issue Jan 18, 2023 · 4 comments
Labels

Comments

@codeuday95
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Greenfield/Brownfield provisioning

greenfield

Terraform Version

1.3.7

Module Version

5.0.0

AzureRM Provider Version

3.39.1

Affected Resource(s)/Data Source(s)

remote_port

Terraform Configuration Files

remote_port = "80,8080" 
not able to take multiple ports

tfvars variables values

not needed

Debug Output/Panic Output

# module.windowsservers.azurerm_network_security_rule.vm[0] will be created
  + resource "azurerm_network_security_rule" "vm" {
      + access                      = "Allow"
      + description                 = "Allow remote protocol in from all locations"
      + destination_address_prefix  = "*"
      + destination_port_range      = "3389,8080"
      + direction                   = "Inbound"
      + id                          = (known after apply)
      + name                        = "allow_remote_3389,8080_in_all"
      + network_security_group_name = "azureclivm-nsg"
      + priority                    = 101
      + protocol                    = "Tcp"
      + resource_group_name         = "Azurecli-Dev-Rg"
      + source_address_prefixes     = [
          + "0.0.0.0/0",
        ]
      + source_port_range           = "*"
    }

Expected Behaviour

No response

Actual Behaviour

Error: creating/updating Security Rule: (Name "allow_remote_3389,8080_in_all" / Network Security Group Name "azureclivm-nsg" / Resource Group "Azurecli-Dev-Rg"): network.SecurityRulesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="SecurityRuleInvalidPortRange" Message="Security rule has invalid Port range. Value provided: 3389,8080. Value should be an integer OR integer range with '-' delimiter. Valid range 0-65535." Details=[]

│ with module.windowsservers.azurerm_network_security_rule.vm[0],
│ on .terraform/modules/windowsservers/main.tf line 347, in resource "azurerm_network_security_rule" "vm":
│ 347: resource "azurerm_network_security_rule" "vm"

Steps to Reproduce

terraform apply

Important Factoids

No response

References

No response

@codeuday95 codeuday95 added the bug label Jan 18, 2023
@lonegunmanb
Copy link
Member

lonegunmanb commented Jan 19, 2023

Hi @codeuday95, thanks for submitting this issue. The network security feature is tend to be a simple one, for complex usage, please use network-security-group module(the current version cannot work properly with latest provider, we'll publish a new version to fix it soon) and inject this nsg via var.network_security_group, thanks!

@codeuday95
Copy link
Author

Hi @lonegunmanb Thanks for the Update ... will definitely wait for the next update

@lonegunmanb
Copy link
Member

Hi @lonegunmanb Thanks for the Update ... will definitely wait for the next update

Hi @codeuday95, we've published v4.0.0 for nsg module, would you please give it a try? Thanks!

@codeuday95
Copy link
Author

hi @lonegunmanb

i tried using network-security-group module in vm here is the code

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
module "network-security-group" {
source = "Azure/network-security-group/azurerm"
version = "4.0.0"
resource_group_name = var.azurerm_resource_group
location = var.location
security_group_name = "${var.azurerm_resource_group}-nsg"
rules = {"RDP": [ "Inbound", "Allow", "Tcp", "", "3389", "RDP" ], "HTTP": [ "Inbound", "Allow", "Tcp", "", "80", "HTTP" ], "HTTPS": [ "Inbound", "Allow", "Tcp", "*", "443"]}
}
output "network_security_group_id" {
value = module.network-security-group.network_security_group_id
}

module "windowsservers" {
source = "Azure/compute/azurerm"
resource_group_name = var.azurerm_resource_group
vm_size = "Standard_B2s"
nb_instances = 1
nb_data_disk = 0
delete_data_disks_on_termination = true
delete_os_disk_on_termination = true
is_windows_image = true
vm_hostname = "azureclivm" // line can be removed if only one VM module per resource group
admin_password = "ComplxP@ssw0rd!"
vm_os_simple = "WindowsServer"
public_ip_dns = ["azureclivm"] // change to a unique name per datacenter region
network_security_group = [ {
id = "/subscriptions/8748e8f0-0c2f-42e9-ab34-6433fec6b0c2/resourceGroups/Azurecli-Dev-Rg/providers/Microsoft.Network/networkSecurityGroups/Azurecli-Dev-Rg-nsg"
} ]

ERROR

│ Error: Invalid value for input variable

│ on main.tf line 34, in module "windowsservers":
│ 34: network_security_group = [ {
│ 35: id = "/subscriptions/8748e8f0-0c2f-42e9-ab34-6433fec6b0c2/resourceGroups/Azurecli-Dev-Rg/providers/Microsoft.Network/networkSecurityGroups/Azurecli-Dev-Rg-nsg"
│ 36: } ]

│ The given value is not suitable for module.windowsservers.var.network_security_group declared at .terraform/modules/windowsservers/variables.tf:180,1-34: object required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants