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.6k stars 4.64k forks source link

json: cannot unmarshal object into Go struct field ServiceEndpointPolicyPropertiesFormat.contextualServiceEndpointPolicies #25791

Open zeusbaba opened 6 months ago

zeusbaba commented 6 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.8.2

AzureRM Provider Version

3.101.0

Affected Resource(s)/Data Source(s)

azurerm_subnet_service_endpoint_storage_policy

Terraform Configuration Files

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = ">=3.0.0, <4.0.0"
    }
  }
}

Debug Output/Panic Output

2024-04-26T07:23:42.666+0200 [ERROR] aztfexport: Importing azurerm_subnet_service_endpoint_storage_policy.res-69: exit status 1

Error: retrieving Subnet Service Endpoint Storage Policy "_e41f87a2_redacted" (Resource Group "rg-redacted"): network.ServiceEndpointPoliciesClient#Get: Failure responding to request: StatusCode=200 -- Original Error: Error occurred unmarshalling JSON - Error = 'json: cannot unmarshal object into Go struct field ServiceEndpointPolicyPropertiesFormat.contextualServiceEndpointPolicies of type string' JSON = '{
  "name": "_e41f87a2_redacted",
  "id": "/subscriptions/a498c7e3-redacted/resourceGroups/rg-redacted/providers/Microsoft.Network/serviceEndpointPolicies/_e41f87a2_redacted",
  "etag": "W/\"96ddffdc-redacted\"",
  "type": "Microsoft.Network/serviceEndpointPolicies",
  "location": "norwayeast",
  "properties": {
    "provisioningState": "Succeeded",
    "resourceGuid": "88e6ea86-redacted",
    "serviceAlias": "/services/Azure/ManagedInstance",
    "serviceEndpointPolicyDefinitions": [],
    "contextualServiceEndpointPolicies": [
      {
        "id": "/subscriptions/a498c7e3-redacted/resourceGroups/rg-redacted/providers/Microsoft.Network/virtualNetworks/vnet-saassb1qa/subnets/managedinstance/contextualServiceEndpointPolicies/ManagedInstanceContextualPolicy"
      }
    ]
  },
  "kind": "Internal"
}'
2024-04-26T07:23:42.809+0200 [ERROR] aztfexport: Importing azurerm_subnet_service_endpoint_storage_policy.res-67: exit status 1

Error: retrieving Subnet Service Endpoint Storage Policy "_e41f87a2_redacted" (Resource Group "rg-redacted"): network.ServiceEndpointPoliciesClient#Get: Failure responding to request: StatusCode=200 -- Original Error: Error occurred unmarshalling JSON - Error = 'json: cannot unmarshal object into Go struct field ServiceEndpointPolicyPropertiesFormat.contextualServiceEndpointPolicies of type string' JSON = '{
  "name": "_e41f87a2_redacted",
  "id": "/subscriptions/a498c7e3-redacted/resourceGroups/rg-redacted/providers/Microsoft.Network/serviceEndpointPolicies/_e41f87a2_redacted",
  "etag": "W/\"83bfed89-redacted\"",
  "type": "Microsoft.Network/serviceEndpointPolicies",
  "location": "norwayeast",
  "properties": {
    "provisioningState": "Succeeded",
    "resourceGuid": "4f9befbd-redacted",
    "serviceAlias": "/services/Azure/ManagedInstance",
    "serviceEndpointPolicyDefinitions": [],
    "contextualServiceEndpointPolicies": [
      {
        "id": "/subscriptions/a498c7e3-redacted/resourceGroups/rg-redacted/providers/Microsoft.Network/virtualNetworks/vnet-saassb1qa/subnets/managedinstance/contextualServiceEndpointPolicies/ManagedInstanceContextualPolicy"
      }
    ]
  },
  "kind": "Internal"
}'

...

Expected Behaviour

we are facing issue while using aztfexport and the error seems to be originated from azurerm provider. see related issue

Actual Behaviour

we are facing issue while using aztfexport and the error seems to be originated from azurerm provider. see related issue

Steps to Reproduce

terraform import azurerm_subnet_service_endpoint_storage_policy.name id

see related comment in >>

Important Factoids

azure Norway

References

No response

zeusbaba commented 6 months ago

appending snippets from terraform.log as well

# from terraform.log (DEBUG)  

2024-04-29T08:50:41.851+0200 [ERROR] provider.terraform-provider-azurerm_v3.99.0_x5: Response contains error diagnostic: diagnostic_detail="" diagnostic_severity=ERROR tf_proto_version=5.4 tf_req_id=863de569-redacted @caller=github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/diag/diagnostics.go:58
  diagnostic_summary=
  | retrieving Subnet Service Endpoint Storage Policy "_e41f87a2_redacted" (Resource Group "rg-redacted"): network.ServiceEndpointPoliciesClient#Get: Failure responding to request: StatusCode=200 -- Original Error: Error occurred unmarshalling JSON - Error = 'json: cannot unmarshal object into Go struct field ServiceEndpointPolicyPropertiesFormat.contextualServiceEndpointPolicies of type string' JSON = '{\r
  |   "name": "_e41f87a2_redacted",\r
  |   "id": "/subscriptions/a498c7e3-redacted/resourceGroups/rg-saas-sb1-qa/providers/Microsoft.Network/serviceEndpointPolicies/_e41f87a2_redacted",\r
  |   "etag": "W/\"83bfed89-redacted\"",\r
  |   "type": "Microsoft.Network/serviceEndpointPolicies",\r
  |   "location": "norwayeast",\r
  |   "properties": {\r
  |     "provisioningState": "Succeeded",\r
  |     "resourceGuid": "4f9befbd-redacted",\r
  |     "serviceAlias": "/services/Azure/ManagedInstance",\r
  |     "serviceEndpointPolicyDefinitions": [],\r
  |     "contextualServiceEndpointPolicies": [\r
  |       {\r
  |         "id": "/subscriptions/a498c7e3-redacted/resourceGroups/rg-saas-sb1-qa/providers/Microsoft.Network/virtualNetworks/vnet-saassb1qa/subnets/managedinstance/contextualServiceEndpointPolicies/ManagedInstanceContextualPolicy"\r
  |       }\r
  |     ]\r
  |   },\r
  |   "kind": "Internal"\r
  | }'
   tf_provider_addr=provider tf_resource_type=azurerm_subnet_service_endpoint_storage_policy tf_rpc=ReadResource @module=sdk.proto timestamp="2024-04-29T08:50:41.851+0200"