Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
If you are interested in working on this issue or have submitted a pull request, please leave a comment
Description
When setting up the ip_configuration block for the azurerm_virtual_network_gateway resource. A public IP is usually used. This is done by allocating a azurerm_public_ip with its allocation_method set to "Dynamic".
This has an issue in the terraform output where the azurerm_public_ip.ip_address attribute is blank due to the allocation occurring after the provisioning of the attached azurerm_virtual_network_gateway resource. The public IP is important for setting up point-to-site connections to the VPN in development. This has a workaround of just executing a terraform refresh after the apply, however the public IP address is stored in the metadata of the resource which can be found in vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2020-07-01/network/models.go::VirtualNetworkGatewayIPConfigurationPropertiesFormat line 40935. Therefore, we could expose the public IP address as an attribute of the azurerm_virtual_network_gateway resource.
Steps to implement change
In resourceVirtualNetworkGatewayRead use the Network.PublicIPsClient to retrieve the IP address of the public IP subresource located in the virtual network gateway properties. This is found in VirtualNetworkGateway.VirtualNetworkGatewayPropertiesFormat.IPConfigurations[**index**].VirtualNetworkGatewayIPConfigurationPropertiesFormat.PublicIPAddress which is of type SubResource. From this we can get the resource group and ID and use that to query the properties of the associated public IP subresource. Once we have that we can add it as a property to the ResourceData returned for the virtual network gateway resource.
Community Note
Description
When setting up the
ip_configuration
block for theazurerm_virtual_network_gateway
resource. A public IP is usually used. This is done by allocating aazurerm_public_ip
with itsallocation_method
set to"Dynamic"
.This has an issue in the terraform output where the
azurerm_public_ip.ip_address
attribute is blank due to the allocation occurring after the provisioning of the attachedazurerm_virtual_network_gateway
resource. The public IP is important for setting up point-to-site connections to the VPN in development. This has a workaround of just executing aterraform refresh
after the apply, however the public IP address is stored in the metadata of the resource which can be found invendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2020-07-01/network/models.go::VirtualNetworkGatewayIPConfigurationPropertiesFormat
line 40935. Therefore, we could expose the public IP address as an attribute of theazurerm_virtual_network_gateway
resource.Steps to implement change
In
resourceVirtualNetworkGatewayRead
use theNetwork.PublicIPsClient
to retrieve the IP address of the public IP subresource located in the virtual network gateway properties. This is found inVirtualNetworkGateway.VirtualNetworkGatewayPropertiesFormat.IPConfigurations[**index**].VirtualNetworkGatewayIPConfigurationPropertiesFormat.PublicIPAddress
which is of typeSubResource
. From this we can get the resource group and ID and use that to query the properties of the associated public IP subresource. Once we have that we can add it as a property to theResourceData
returned for the virtual network gateway resource.New or Affected Resource(s)
Potential Terraform Configuration