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.58k stars 4.62k forks source link

azurerm_api_management_subscription doesn't accept administrator as user_id #15075

Closed jeanpaulsmit closed 7 months ago

jeanpaulsmit commented 2 years ago

Community Note

Terraform (and AzureRM Provider) Version

Terraform 0.12.31 AzureRM 2.92

Affected Resource(s)

Debug Output

Error: Can not parse "user_id" as a resource id: Cannot parse Azure ID: parse "1": invalid URI for request2022-01-22T23:55:55.062+0100 [WARN] plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"

Expected Behaviour

Allow to set the subscription key on the Administrator for a certain product.

Actual Behaviour

Error: Can not parse "user_id" as a resource id: Cannot parse Azure ID: parse "1": invalid URI for request2022-01-22T23:55:55.062+0100 [WARN] plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"

I would expect to be able to set the subscription key on the administrator account, and leave the display name empty like is in the portal for administrator accounts.

Steps to Reproduce

Try to set the subscription key for the Administrator user, which can be found as "1" in the list of users. However, this is not accepted by the apply command.

resource "azurerm_api_management_subscription" "subscriptionManagementAdmin" { api_management_name = azurerm_api_management.apim.name resource_group_name = azurerm_resource_group.rg.name product_id = "productId" user_id = "1" display_name = "Administrator" state = "active" primary_key = "abc" allow_tracing = true }

  1. terraform apply
jeanpaulsmit commented 2 years ago

Actually, I think the naming is confusing. I think it's looking for the Id of a user, not the user_id, so maybe this can be solved by renaming.

xuzhang3 commented 2 years ago

@jeanpaulsmit The user_id is a resource ID not a simple ID as an number. Example user_id : "/subscriptions/{subID}resourceGroups/{resourceGroup}/providers/Microsoft.ApiManagement/service/{APIMService}/users/{id}"

jeanpaulsmit commented 2 years ago

@xuzhang3 yes, correct, but exactly that fact makes the naming confusing. user_id is not supposed to be the id of the user, but the id of the resource.

xuzhang3 commented 2 years ago

@jeanpaulsmit Yes, the name here is confusing. This property should rename to owner_id as the API(https://docs.microsoft.com/en-us/rest/api/apimanagement/current-ga/subscription/create-or-update#request-body) defines and the doc should document that this is a user ID path not a simple numeric ID.

rcskosir commented 7 months ago

Thanks for opening this issue. This was a problem in the 2.x version of the provider which is no longer actively maintained. If this is still an issue with the 3.x version of the provider please do let us know by opening a new issue, thanks!

github-actions[bot] commented 6 months ago

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.