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

Unable to apply tags to multiple API operations #15921

Closed
alexwiese opened this issue Mar 21, 2022 · 6 comments
Closed

Unable to apply tags to multiple API operations #15921

alexwiese opened this issue Mar 21, 2022 · 6 comments

Comments

@alexwiese
Copy link
Contributor

alexwiese commented Mar 21, 2022

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

Terraform (and AzureRM Provider) Version

Terraform v1.1.7
on windows_amd64
+ provider registry.terraform.io/hashicorp/azurerm v2.99.0

Affected Resource(s)

  • azurerm_api_management_api_operation_tag

Terraform Configuration Files

resource "azurerm_api_management_api_operation" "example" {
  operation_id        = "user-delete"
  api_name            = azurerm_api_management_api.api.name
  api_management_name = var.api_management_name
  resource_group_name = var.resource_group_name
  display_name        = "Delete User Operation"
  method              = "DELETE"
  url_template        = "/users"
  description         = "This can only be done by the logged in user."

  response {
    status_code = 200
  }
}

resource "azurerm_api_management_api_operation_tag" "example" {
  api_operation_id = azurerm_api_management_api_operation.example.id
  name             = "example-Tag"
   display_name     = "example-Tag"
}


resource "azurerm_api_management_api_operation" "example2" {
  operation_id        = "user-get"
  api_name            = azurerm_api_management_api.api.name
  api_management_name = var.api_management_name
  resource_group_name = var.resource_group_name
  display_name        = "Get User Operation"
  method              = "GET"
  url_template        = "/users"
  description         = "This can only be done by the logged in user."

  response {
    status_code = 200
  }
}

resource "azurerm_api_management_api_operation_tag" "example2" {
  api_operation_id = azurerm_api_management_api_operation.example.id
  name             = "example-Tag"
  display_name     = "example-Tag"
}

Debug Output

Expected Behaviour

Both operations, user-delete and user-get, should be tagged with the "example-Tag".

Actual Behaviour

One operation (user-get) gets tagged with "example-Tag".

An error occurs when applying the tag to user-delete:

Error: A resource with the ID "/subscriptions/xyz/resourceGroups/abc/providers/Microsoft.ApiManagement/service/apim/apis/aaa/operations/user-delete/tags/example-Tag" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_api_management_api_operation_tag" for more information.

Steps to Reproduce

  1. terraform apply

References

@xuzhang3
Copy link
Contributor

This is a bug, azurerm_api_management_api_operation_tag try get the tags at API level which will get a tag with the same name defined in another API_Operation. The get should limited to operation level.

@arkiaconsulting
Copy link

to me this issue is fixed (tested with 3.30.0)

@arkiaconsulting
Copy link

@xuzhang3 is there any reason why the tag is created at service level, instead of being created at Api level ? In the project I work on, we only have permissions at the Api level, not at the service level.

@arkiaconsulting
Copy link

@xuzhang3 is there any reason why the tag is created at service level, instead of being created at Api level ? In the project I work on, we only have permissions at the Api level, not at the service level.

Now I understand: tags does only exist at service level, and can be associated either at Api level, either at Api operation level.

@rcskosir
Copy link
Contributor

Thanks for taking the time to submit this issue. It looks like this has been resolved as of #16006. As such, I am going to mark this issue as closed.

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants