Skip to content

dataworkaround: add workaround for resources 29885#4691

Open
teowa wants to merge 2 commits into
hashicorp:mainfrom
teowa:add-resource-workaround-29885
Open

dataworkaround: add workaround for resources 29885#4691
teowa wants to merge 2 commits into
hashicorp:mainfrom
teowa:add-resource-workaround-29885

Conversation

@teowa

@teowa teowa commented Feb 26, 2025

Copy link
Copy Markdown
Contributor

related to:
workaround to covert the string type to interface

"nestedItem": {
"type": "String",
"nullable": false,
"referenceName": null,
"referenceNameIsCommonType": null

hashicorp/terraform-provider-azurerm#26670
Azure/azure-rest-api-specs#29885

@sreallymatt sreallymatt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @teowa - this is a fairly old data workaround that was seemingly missed. Is this still required?

@teowa

teowa commented Mar 31, 2026

Copy link
Copy Markdown
Contributor Author

Hi @sreallymatt , by my test the issue still exists, so we still needs the patch.

reproduce steps

create resources with below config:

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "=4.66.0"
    }
  }
}
provider "azurerm" {
  features {}
}
resource "azurerm_resource_group" "management_privatelink" {
  name     = "management_privatelink"
  location = "eastus"
}
resource "azurerm_resource_management_private_link" "management_privatelink" {
  name                = "management_privatelink"
  resource_group_name = azurerm_resource_group.management_privatelink.name
  location            = azurerm_resource_group.management_privatelink.location
}
resource "random_uuid" "management_privatelink" {
}
data "azurerm_subscription" "current" {
}

resource "azurerm_management_group" "example_parent" {
  display_name = "ParentGroup"
  subscription_ids = []
}

resource "azurerm_resource_management_private_link_association" "management_privatelink" {
  name                                = random_uuid.management_privatelink.result
  management_group_id                 = azurerm_management_group.example_parent.id
  resource_management_private_link_id = azurerm_resource_management_private_link.management_privatelink.id
  public_network_access_enabled       = true # Presumably we will eventually want to change this to false
}

resource "azurerm_virtual_network" "management_privatelink" {
  name                = "management_privatelink-network"
  address_space       = ["10.0.0.0/16"]
  location            = azurerm_resource_group.management_privatelink.location
  resource_group_name = azurerm_resource_group.management_privatelink.name
}

resource "azurerm_subnet" "endpoint" {
  name                 = "endpoint"
  resource_group_name  = azurerm_resource_group.management_privatelink.name
  virtual_network_name = azurerm_virtual_network.management_privatelink.name
  address_prefixes     = ["10.0.2.0/24"]
}

resource "azurerm_private_endpoint" "management_privatelink" {
  name                = "management_privatelink"
  location            = azurerm_resource_group.management_privatelink.location
  resource_group_name = azurerm_resource_group.management_privatelink.name
  subnet_id           = azurerm_subnet.endpoint.id
  private_service_connection {
    name                           = "management_privatelink"
    private_connection_resource_id = azurerm_resource_management_private_link.management_privatelink.id
    is_manual_connection           = false
    subresource_names = [
      "ResourceManagement",
    ]
  }
}

run terraform apply, then after the resources are provisioned, run terraform plan, it will show error:

╷
│ Error: retrieving Resource Management Private Link (Subscription: "<redacted>"
│ Resource Group Name: "management_privatelink"
│ Resource Management Private Link Name: "management_privatelink"): unmarshaling response body: json: cannot unmarshal object into Go struct field ResourceManagementPrivateLinkEndpointConnections.properties.privateEndpointConnections of type string
│ 
│   with azurerm_resource_management_private_link.management_privatelink,
│   on main.tf line 8, in resource "azurerm_resource_management_private_link" "management_privatelink":
│    8: resource "azurerm_resource_management_private_link" "management_privatelink" {
│ 
│ retrieving Resource Management Private Link (Subscription: "<redacted>"
│ Resource Group Name: "management_privatelink"
│ Resource Management Private Link Name: "management_privatelink"): unmarshaling response body: json: cannot unmarshal object into Go struct field
│ ResourceManagementPrivateLinkEndpointConnections.properties.privateEndpointConnections of type string
╵

retrieve the actual resource, the privateEndpointConnections is list of objects:

az rest --method get --uri "/subscriptions/<redacted>/resourceGroups/management_privatelink/providers/Microsoft.Authoriza
tion/resourceManagementPrivateLinks/management_privatelink?api-version=2020-05-01"
{
  "id": "/subscriptions/<redacted>/resourceGroups/management_privatelink/providers/Microsoft.Authorization/resourceManagementPrivateLinks/management_privatelink",
  "location": "eastus",
  "name": "management_privatelink",
  "properties": {
    "privateEndpointConnections": [
      {
        "id": "/subscriptions/<redacted>/resourceGroups/management_privatelink/providers/Microsoft.Authorization/resourceManagementPrivateLinks/management_privatelink/privateEndpointConnections/management_privatelink.ffc41b9c-f0c1-49a5-ad45-cbb64375fc48",
        "name": "management_privatelink.ffc41b9c-f0c1-49a5-ad45-cbb64375fc48",
        "properties": {
          "privateEndpoint": {
            "id": "/subscriptions/<redacted>/resourceGroups/management_privatelink/providers/Microsoft.Network/privateEndpoints/management_privatelink"
          },
          "privateLinkServiceConnectionState": {
            "description": "Auto-approved",
            "status": "Approved"
          },
          "provisioningState": "Succeeded"
        },
        "type": "Microsoft.Authorization/resourceManagementPrivateLinks/privateEndpointConnections"
      }
    ]
  },
  "type": "Microsoft.Authorization/resourceManagementPrivateLinks"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants