Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_api_management Data Source fails with Invalid Structure - Exception in case of User Assigned Managed Identity #10136

Closed
salvisbh opened this issue Jan 11, 2021 · 2 comments · Fixed by #10429

Comments

@salvisbh
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

The Data Source azurerm_api_management provides an identity block and as a preview feature support for User Assigned Managed Identities. In our environment, the provider throws the following error message:

Error: setting `identity`: identity.0.identity_ids: '': source data must be an array or slice, got struct

Terraform (and AzureRM Provider) Version

  • Terraform v0.14.2
  • Terraform azurerm 2.41.0

Affected Resource(s)

  • azurerm_api_management

Terraform Configuration Files

data "azurerm_api_management" "apim" {
  name                = var.api_management_name
  resource_group_name = var.resource_group_name
}

resource "azurerm_api_management_policy" "global" {
  api_management_id = data.azurerm_api_management.apim.id
  xml_content       = file(var.xml_policy_file)
}

Debug Output

https://gist.github.com/salvisbh/3c5c2d7afc10f1b4c26b0207481017f8

Panic Output

tf_plan: Running...
tf_plan: subscription to deploy to xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx
tf_plan: Running in regular mode.
Acquiring state lock. This may take a few moments...

Error: setting `identity`: identity.0.identity_ids: '': source data must be an array or slice, got struct

  on module/caz_apim_policies/main.tf line 2, in data "azurerm_api_management" "apim":
   2: data "azurerm_api_management" "apim" {

The terminal process "/bin/bash '-c', 'deploy plan --mode remote --subscription ${DEPLOY_SUBSCRIPTION} --backend-subscription ${BACKEND_SUBSCRIPTION} --backend-resource-group ${BACKEND_RESOURCE_GROUP} --backend-storage-account-name ${BACKEND_STORAGE_ACCOUNT_NAME} --backend-storage-account-container ${BACKEND_STORAGE_ACCOUNT_CONTAINER_NAME} --tf-state-name ${TF_STATE_NAME} --location ${LOCATION} --force --debug'" terminated with exit code: 1.

Identity-Structur in Terraform-State:

"identity": [
{
"identity_ids": [
"/subscriptions/xxxxxxxxxxxx/resourcegroups/caz-preprod-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/caz-preprod-apim-mi"
],
"principal_id": "",
"tenant_id": "xxxxxxxxx",
"type": "UserAssigned"
}
],

Expected Behaviour

Actual Behaviour

Data Source fails.

Steps to Reproduce

Important Factoids

  • Location: westeurope

References

@ghost
Copy link

ghost commented Feb 5, 2021

This has been released in version 2.46.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.46.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Mar 5, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants