hashicorp / go-azure-helpers

This repository contains various helpers and wrappers for working with Azure and the Azure SDK for Go.
Mozilla Public License 2.0
57 stars 43 forks source link

Added `UnmarshalJSON` function for `LegacySystemAndUserAssignedMap` to transform API value as required #231

Closed sinbai closed 4 months ago

sinbai commented 5 months ago

If the type of identity is set to SystemAssigned, UserAssigned(w/space), Terraform will return the following 400 error even though the type has not changed when updating the resource. It is caused by the internal error (internal error: the legacy SystemAssigned,UserAssigned identity type should be being converted to the schema type - this is a bug). In this case, the type value returned from API is SystemAssigned,UserAssigned(no space) causing this internal error to occur.

Error:
`performing CreateOrUpdate: unexpected status 400 with error: InvalidResource: The resource definition is invalid.`

Use the consistent value SystemAssigned, UserAssigned internally - transform from the API value (SystemAssigned,UserAssigned) as required when Unmarshalling the JSON payload to fix https://github.com/hashicorp/terraform-provider-azurerm/issues/24390.

Test result: PASS: TestLegacySystemAndUserAssignedMapUnmarshal (0.00s)

Related PR: https://github.com/hashicorp/terraform-provider-azurerm/pull/25542