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

terraform always wants to recreate azurerm_api_management_api_tag #24705

Closed
1 task done
sven5 opened this issue Jan 30, 2024 · 9 comments · Fixed by #25168
Closed
1 task done

terraform always wants to recreate azurerm_api_management_api_tag #24705

sven5 opened this issue Jan 30, 2024 · 9 comments · Fixed by #25168

Comments

@sven5
Copy link

sven5 commented Jan 30, 2024

Is there an existing issue for this?

  • I have searched the existing issues

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 and review the contribution guide to help.

Terraform Version

1.7.1

AzureRM Provider Version

3.89.0

Affected Resource(s)/Data Source(s)

azurerm_api_management_api_tag

Terraform Configuration Files

Hi,

When dealing with azurerm_api_management_api_tag terraform always wants to recreate the same item because the suffix ;rev=10 is being ignored.

Example:

Debug Output/Panic Output

Output from tf plan

module.api_management_2[0].azurerm_api_management_api_tag.apim_api_tag[11] must be replaced

-/+ resource "azurerm_api_management_api_tag" "apim_api_tag" {
      ~ api_id = "/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.ApiManagement/service/apim001/apis/atest-2-v7" -> "/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.ApiManagement/service/apim001/apis/test-2-v7;rev=10" # forces replacement
      ~ id     = "/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.ApiManagement/service/apim001/apis/test-2-v7/tags/test2" -> (known after apply)
        name   = "test2"
    }

After applying, the same change is still present when issuing a new plan.

Output from tf state for this resource:

module.api_management_2[0].azurerm_api_management_api_tag.apim_api_tag[11]:

resource "azurerm_api_management_api_tag" "apim_api_tag" {
    api_id = "/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.ApiManagement/service/apim001/apis/test-2-v7"
    id     = "/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.ApiManagement/service/apim001/apis/test-2-v7/tags/test2"
    name   = "test2"
}

We can see that the suffix ;rev=10 is missing in the state.

Expected Behaviour

The API tag should not be identified as a change because it's already present.

Actual Behaviour

The API tag is always recreated.

Steps to Reproduce

No response

Important Factoids

No response

References

No response

@alexwiese
Copy link
Contributor

Looks like this, and a few other issues, were introduced by #23031

alexwiese added a commit to alexwiese/terraform-provider-azurerm that referenced this issue Mar 7, 2024
This fixes hashicorp#24705 by removing the code that updates the API ID to no longer have the `;rev=XYZ` revision segment in the ID.
This was causing the API tag to be recreated on each run, even if the tag did not change.
@Aujjani
Copy link

Aujjani commented Apr 15, 2024

Hello @sven5 @alexwiese i am still facing this issue .
is there any fix ?

in my case with each plan 45 tags get replaced so its a big issue for me .
please help

@sven5
Copy link
Author

sven5 commented Apr 15, 2024

I haven't been working on our terraform scripts for a while, but I assume this still exists.

@alexwiese
Copy link
Contributor

alexwiese commented Apr 15, 2024

Hi @Aujjani

You can workaround the issue by stripping the suffix off of the tag ID before passing it as an input to the resources.

api_id = split(";", azurerm_api_management_api.example.id)[0]

The PR that fixes this (#25168) is still waiting to be merged by the maintainers.

@sven5
Copy link
Author

sven5 commented May 23, 2024

We're still waiting for the merge... 😢

stephybun pushed a commit that referenced this issue Jun 5, 2024
* Don't update the api_id of the API tag

This fixes #24705 by removing the code that updates the API ID to no longer have the `;rev=XYZ` revision segment in the ID.
This was causing the API tag to be recreated on each run, even if the tag did not change.

* Update api_management_api_tag_resource.go

* Update api_management_api_tag_resource.go

* Only include changes in v4.0

* Format
@github-actions github-actions bot added this to the v3.107.0 milestone Jun 5, 2024
@J0F3
Copy link

J0F3 commented Jun 24, 2024

@sven5 @stephybun
Why is this issue closed now? I think the problem stillt happens with the latest version of the provider. Or did I miss something?

@stephybun
Copy link
Member

@J0F3 there is a detailed discussion within the PR on the issue as well the fix.

TL;DR we can't roll the fix out until we release the next major version 4.0 of the provider since all of the tags need to be recreated. This has been implemented behind a feature flag so the functionality is in the provider, but won't be switched on until 4.0.

@J0F3
Copy link

J0F3 commented Jun 24, 2024

@stephybun Ah ok, got you. Thanks for the update.
But then I still think that this issue should be kept open until the problem is really fixed and the fix is available for everyone. Otherwise I find it very confusing and in additional the chances are high that the problem get reported again with other issues because no open issue can be found anymore.

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 Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants