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.47k stars 4.55k forks source link

azurerm_private_link_service not providing private_ip_address under nat_ip_configuration #26371

Open dtu-ruth opened 4 weeks ago

dtu-ruth commented 4 weeks ago

Is there an existing issue for this?

Community Note

Terraform Version

1.6.6

AzureRM Provider Version

3.108.0

Affected Resource(s)/Data Source(s)

azurerm_private_link_service

Terraform Configuration Files

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "3.108.0"
    }
  }

}

provider "azurerm" {
  subscription_id = "xxx"
  tenant_id       = "xxx"
  features {}
  use_msi = false
}

data "azurerm_private_link_service" "example" {
  name                = "<private_link_service_resource>"
  resource_group_name = "<resource_group_containing_private_link_service>"
}

output "output" {
  value = data.azurerm_private_link_service.example
}

Debug Output/Panic Output

data.azurerm_private_link_service.example: Reading...
data.azurerm_private_link_service.example: Read complete after 0s [id=/subscriptions/<sub_id>/resourceGroups/<rg_name>/providers/Microsoft.Network/privateLinkServices/<pls_name>]

Changes to Outputs:
  + output = {
      + alias                                       = "<stripped>.uksouth.azure.privatelinkservice"
      + auto_approval_subscription_ids              = []
      + enable_proxy_protocol                       = false
      + id                                          = "/subscriptions/<subid>/resourceGroups/<rg_name>/providers/Microsoft.Network/privateLinkServices/<name_of_pls>"
      + load_balancer_frontend_ip_configuration_ids = [
          + "/subscriptions/<sub_id>/resourceGroups/<rg_name>/providers/Microsoft.Network/loadBalancers/kubernetes-internal/frontendIPConfigurations/<stripped>-loadbalancer",
        ]
      + location                                    = "uksouth"
      + name                                        = "<name_of_pls>"
      + nat_ip_configuration                        = [
          + {
              + name                       = "internal-lb-nat-ip-client"
              + primary                    = true
              + private_ip_address         = "" # THIS IS MISSING :(
              + private_ip_address_version = "IPv4"
              + subnet_id                  = "/subscriptions/<sub_id>/resourceGroups/<rg_group>/providers/Microsoft.Network/virtualNetworks/<vnet_name>/subnets/endpoint"
            },
        ]
      + resource_group_name                         = "<rg_name>"
      + tags                                        = {}
      + timeouts                                    = null
      + visibility_subscription_ids                 = []
    }

You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.

Expected Behaviour

That private_ip_address is fetched and visible.

Actual Behaviour

private_ip_address is providing a null value.

Steps to Reproduce

Create a private link service, and then modify the given terraform configuration files and do a terraform plan.

Important Factoids

No response

References

No response

ziyeqf commented 3 weeks ago

Hi @dtu-ruth, thanks for reporting.

I can reproduce this issue. Per my testing, the IP address will only be shown if its allocation method is Static. For Dynamic ones, they will not be shown. ( even if it's shown, depending on a dynamic IP address might not be a good idea )

If the resource was created by Terraform, specifying the private_ip_address will turn the allocation method to static.

For any further questions please leave comments. Thanks