Open nciross opened 1 week ago
I am also seeing this error when trying to create policy fragment resources in APIM. Terraform version is 1.9.2 AzureRM version is 3.116.0
The files are read during plan and display to the console, but fail with a 404 when applying.
Hi @nciross thanks for opening this issue. Could you please specify the following format
and try again?
format = "rawxml"
I'm seeing this error also with the configuration below Azurerm: 3.116.0 Terrform: 1.9.5
resource "azurerm_api_management_policy_fragment" "rate_limit_jwt" {
name = "rate-limit-jwt"
api_management_id = azurerm_api_management.hub_apim.id
format = "rawxml"
value = <<XML
<fragemnt>
<rate-limit-by-key calls="90"
renewal-period="60"
counter-key="@(context.Request.Headers.GetValueOrDefault("Authorization","").AsJwt()?.Subject)" />
</fragement>
XML
}
On my side, the resource could be created successfully by following the steps below. Could you try to reproduce the error code with it?
Step1: Create 'azurerm_api_management_policy_fragment' by the following config.
terraform {
required_providers {
azurerm = {
version = "3.116.0"
}
}
}
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-27356-0914"
location = "eastus"
}
resource "azurerm_api_management" "test" {
name = "acctestAM-27356-0914"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
publisher_name = "pub1"
publisher_email = "pub1@email.com"
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 which is updated"
value = <<XML
<fragment>
<choose>
<when condition="@(context.Request.Headers.ContainsKey("x-correlationId"))">
<!-- Header is present, pass the request through -->
</when>
<otherwise>
<!-- Header is not present, generate GUID and assign to header -->
<set-header name="x-correlationId" exists-action="override">
<value>@(Guid.NewGuid().ToString())</value>
</set-header>
<!-- Pass the request through -->
</otherwise>
</choose>
</fragment>
XML
#format = "rawxml"
}
Result:
Step2: Uncomment format = "rawxml"
in above config, run terraform apply.
Result:
Changing the format from XML to RAWXML seems to have solved this issue for me
Is there an existing issue for this?
Community Note
i want to add new plicy fragment but i have this error
Terraform Version
1.9.1
AzureRM Provider Version
4.1.0
Affected Resource(s)/Data Source(s)
azurerm_api_management_policy_fragment
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
adding "apim-pol-frag-correlation-id
Actual Behaviour
Resource not found
Steps to Reproduce
No response
Important Factoids
No response
References
No response