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

Unexpected status 404 (404 Not Found) with error: ResourceNotFound: PolicyFragment not found. #26959

Closed
1 task done
nikhil0499 opened this issue Aug 7, 2024 · 4 comments · Fixed by #26965
Closed
1 task done

Comments

@nikhil0499
Copy link

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 comments along the lines of "+1", "me too" or "any updates", 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

v1.9.1

AzureRM Provider Version

3.105.0

Affected Resource(s)/Data Source(s)

azurerm_api_management_policy_fragment

Terraform Configuration Files

resource "azurerm_api_management_policy_fragment" "policy_fragments" {
  
  api_management_id = var.apim_instance_ids[var.environment]
  name              = var.name
  format            = "xml"
  value             = var.policy_fragments_dir
  description       = var.description
  
}

Debug Output/Panic Output

Error: creating Policy Fragment (Subscription: "xxx" Resource Group Name: "xxxx" Service Name: "xxx" Policy Fragment Name: "apim-common-cors"): polling after CreateOrUpdate: executing request: unexpected status 404 (404 Not Found) with error: ResourceNotFound: PolicyFragment not found.

Expected Behaviour

Should have created the policy fragments

Actual Behaviour

Error: creating Policy Fragment (Subscription: "xxx" Resource Group Name: "xxx" Service Name: "xxx" Policy Fragment Name: "apim-common-cors"): polling after CreateOrUpdate: executing request: unexpected status 404 (404 Not Found) with error: ResourceNotFound: PolicyFragment not found.

Steps to Reproduce

No response

Important Factoids

No response

References

No response

@sinbai
Copy link
Contributor

sinbai commented Aug 8, 2024

Hi @nikhil0499 thanks for opening this issue. Unfortunately, I could not reproduce the issue with the following tf config. Could you reproduce with it?


provider "azurerm" {
  features {}
}

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "3.105.0"
    }
  }
}

resource "azurerm_resource_group" "test" {
  name     = "testRG-26959"
  location = "eastus"
}

resource "azurerm_api_management" "test" {
  name                = "testAM-26959"
  location            = azurerm_resource_group.test.location
  resource_group_name = azurerm_resource_group.test.name
  publisher_name      = "pub1"
  publisher_email     = "[email protected]"
  sku_name            = "Consumption_0"
}

resource "azurerm_api_management_policy_fragment" "test" {
  api_management_id = azurerm_api_management.test.id
  name              = azurerm_api_management.test.name
  description       = "Some descriptive text"
  value             = file("api_management_policy_fragment_test_xml.xml")
}

Actual:
image

@nikhil0499
Copy link
Author

nikhil0499 commented Aug 8, 2024

Hi @sinbai , Good Day !
I think I might have found the root cause, so basically its with the value of "format" parameter in azurerm_api_management_policy_fragment block.

So initially when you see the resource block I had used "xml" , but after changing it to "rawxml", it started to work.

resource "azurerm_api_management_policy_fragment" "policy_fragments" {
  
  api_management_id = var.apim_instance_ids[var.environment]
  name              = var.name
  format            = "rawxml"
  value             = var.policy_fragments_dir
  description       = var.description
  
}

And one more thing , In this https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/api_management_policy_fragment docs , I could find the "format" param is required.
not sure how it worked for you without adding the format.
Screenshot 2024-08-08 130400

@sinbai
Copy link
Contributor

sinbai commented Aug 8, 2024

Hi @sinbai , Good Day ! I think I might have found the root cause, so basically its with the value of "format" parameter in azurerm_api_management_policy_fragment block.

So initially when you see the resource block I had used "xml" , but after changing it to "rawxml", it started to work.

resource "azurerm_api_management_policy_fragment" "policy_fragments" {
  
  api_management_id = var.apim_instance_ids[var.environment]
  name              = var.name
  format            = "rawxml"
  value             = var.policy_fragments_dir
  description       = var.description
  
}

And one more thing , In this https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/api_management_policy_fragment docs , I could find the "format" param is required. not sure how it worked for you without adding the format. Screenshot 2024-08-08 130400

Excellent. Thanks for finding this out. Actually format should be optional and default to xml. I would submit a PR to fix this doc issue as soon as possible. Thanks again.

@github-actions github-actions bot added this to the v3.115.0 milestone Aug 8, 2024
@rcskosir rcskosir added the bug label Aug 19, 2024
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 Sep 19, 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.

3 participants