hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.59k stars 4.63k forks source link

azurerm_virtual_network_gateway - Private IP Enabled, Static assigned, no parameter for IP Address #15219

Open jdelforno opened 2 years ago

jdelforno commented 2 years ago

Community Note

Terraform (and AzureRM Provider) Version

terraform -v Terraform v1.1.2 on windows_amd64

Affected Resource(s)

azurerm_virtual_network_gateway

Terraform Configuration Files

Not entirely sure what to paste here.

Debug Output

Private IP address is required when privateIPAllocationMethod is Static in IP configuration

Expected Behaviour

Documentation fails to list a method to supply a static IP Address, which is now required.

Actual Behaviour

Static isn't possible however it's stated as an option.

Steps to Reproduce

`resource "azurerm_virtual_network_gateway" "example" { name = "test" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name

type = "Vpn" vpn_type = "RouteBased"

active_active = false enable_bgp = false sku = "Basic"

ip_configuration { name = "vnetGatewayConfig" public_ip_address_id = azurerm_public_ip.example.id private_ip_address_allocation = "Static" subnet_id = azurerm_subnet.example.id } }`

Important Factoids

References

https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network_gateway

`The ip_configuration block supports:

name - (Optional) A user-defined name of the IP configuration. Defaults to vnetGatewayConfig.

private_ip_address_allocation - (Optional) Defines how the private IP address of the gateways virtual interface is assigned. Valid options are Static or Dynamic. Defaults to Dynamic.

subnet_id - (Required) The ID of the gateway subnet of a virtual network in which the virtual network gateway will be created. It is mandatory that the associated subnet is named GatewaySubnet. Therefore, each virtual network can contain at most a single Virtual Network Gateway.

public_ip_address_id - (Required) The ID of the public ip address to associate with the Virtual Network Gateway.

`

aristosvo commented 2 years ago

The property for the Private IP is ReadOnly specified in the REST API specs. This blocks the possibility to set it in the resource.

@jdelforno Is it a solution for you to have the Static option removed instead for clarity? As far as I know it is also not possible to set this in other provisioning options like ARM and az cli.

jdelforno commented 2 years ago

@aristosvo

If there's no way to set a static private ip address, then the only option for the allocation method is Dynamic and Static should be removed as an 'option' from documentation.

private_ip_address_allocation - (Optional) Defines how the private IP address of the gateways virtual interface is assigned. Valid options are Static or Dynamic. Defaults to Dynamic.

kostas-nd commented 1 year ago

It would also help when having it as "Dynamic" to expose that private IP address (azurerm_virtual_network_gateway..ip_configuration.ip_address) so it can be used in other places to one's terraform code.