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.51k stars 4.6k forks source link

Lack of info in terraform output to fetch proper value #13463

Open tmiroslav opened 2 years ago

tmiroslav commented 2 years ago

Community Note

Terraform (and AzureRM Provider) Version

Terraform - 0.14.11 azurerm - 2.71.0

Terraform Configuration Files

resource "azurerm_vpn_gateway" "azure_vpngw" {
  provider            = azurerm.azure_clusters
  name                = "azure_vpngw"
  location            = azurerm_resource_group.azure_networking.location
  resource_group_name = azurerm_resource_group.azure_networking.name
  virtual_hub_id      = azurerm_virtual_hub.azure_hub.id
  bgp_settings {
    asn         = 65515
    peer_weight = 50
    instance_0_bgp_peering_address {
      custom_ips = ["169.254.21.9"]
    }
    instance_1_bgp_peering_address {
      custom_ips = ["169.254.22.9"]
    }
  }
}

Expected Behaviour

To have unique identification of public IP in output.

Actual Behaviour

resource given above producing state file which is (I am coping just part of it I consider relevant here)

"type": "azurerm_vpn_gateway",
      "name": "azure_vpngw",
      "provider": "provider[\"registry.terraform.io/hashicorp/azurerm\"].azure_clusters",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "bgp_settings": [
              {
                "asn": 65515,
                "bgp_peering_address": "",
                "instance_0_bgp_peering_address": [
                  {
                    "custom_ips": [
                      "169.254.21.1"
                    ],
                    "default_ips": [
                      "10.255.176.12"
                    ],
                    "ip_configuration_id": "Instance0",
                    "tunnel_ips": [
                      "10.255.176.4",
                      "20.185.79.231"
                    ]

So, given resource producing tunnel_ips. tunnel_ips is set of string. One IP is public and second is private IP. I need to fetch public IP and use it in another resource. There is no way I can determine which one of those 2 is public. Is it possible to create output where existing variable structure would go one level below tunnel_ips and point to public_ip, so I can access it with something like: azurerm_vpn_gateway.azure_vpngw.bgp_settings[0].instance_0_bgp_peering_address[0].tunnel_ips.public_ip With current behavior I can never be sure that I fetch public IP. If you have any hint , would you pease let me know.

Steps to Reproduce

Create a resource mentioned above.

thevman commented 8 months ago

did you ever find a solution to this? I'm having the same problem.