-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Microsoft.ApiManagement Error: unexpected segment "policies/policy" in 3.71.0 version #23095
Comments
Hi @abbasbaman thanks for opening this issue. Unfortunately, I could not reproduce this issue by the following tf configuration and repro steps. Could you reproduce with it? Also , is it possible to provide the detailed reproduce steps and tf configuration to help reproduce/troubleshoot? Step1: Create
Step2: Update the version of Terraform Provider to Step3: Run "terraform init -upgrade" => No error Step4: Run "terraform plan" => No error.
|
Hello, I have encountered a similar issue but in another APIM Policy Resource:
using:
Affects: |
Hi @sinbai I believe it's functioning correctly for certain APIs, but there are instances where it's failing. Could you please attempt it with different APIs? |
For Step1: Create azurerm_api_management_api_operation_policy with the following tf config.(the version of Terraform Provider is 3.69.0).
Step2: Update the version of Terraform Provider to 3.71.0. Step3: Run "terraform init -upgrade" => No error |
@sinbai I tried to cut out one of our APIM Terraform Config for debugging, I needed to refactor some values to redact company details. I hope this helps for debugging terraform {
required_version = "1.5.6"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.69.0"
}
}
}
resource "azurerm_resource_group" "rsg" {
location = "westeurope"
name = "APIM_RSG"
}
resource "azurerm_api_management" "apim" {
name = "someapiname"
resource_group_name = azurerm_resource_group.rsg.name
location = "westeurope"
publisher_name = "Publisher Name"
publisher_email = "[email protected]"
sku_name = "Developer"
identity {
type = "SystemAssigned"
}
security {
enable_backend_ssl30 = false
enable_backend_tls10 = false
enable_backend_tls11 = false
enable_frontend_ssl30 = false
enable_frontend_tls10 = false
enable_frontend_tls11 = false
triple_des_ciphers_enabled = false
}
policy {
xml_content = <<-XML
<policies>
<inbound>
<set-variable name="appgw-fqdn" value="{{appgw-fqdn}}" />
<set-variable name="apps-fqdn" value="{{apps-fqdn}}" />
</inbound>
<backend>
<forward-request />
</backend>
<outbound />
<on-error />
</policies>
XML
}
lifecycle {
ignore_changes = [hostname_configuration]
}
}
resource "azurerm_api_management_api_version_set" "api" {
name = "redacted-name"
resource_group_name = azurerm_api_management.apim.resource_group_name
api_management_name = azurerm_api_management.apim.name
display_name = "Some API Name"
versioning_scheme = "Segment"
}
resource "azurerm_api_management_api" "api_v1" {
name = "redacted-name-v1"
resource_group_name = azurerm_api_management.apim.resource_group_name
api_management_name = azurerm_api_management.apim.name
revision = "1"
display_name = "Some API Name"
path = "path"
protocols = ["https"]
service_url = "redacted.example.com"
oauth2_authorization {
authorization_server_name = "some-server-name"
scope = "Monitoring RemoteControl RegisterDevice"
}
lifecycle {
ignore_changes = [
description,
display_name,
]
}
}
resource "azurerm_api_management_api_operation_policy" "api_v1_ws" {
api_name = azurerm_api_management_api.api_v1.name
api_management_name = azurerm_api_management_api.api_v1.api_management_name
resource_group_name = azurerm_api_management_api.api_v1.resource_group_name
operation_id = "ws"
xml_content = <<-XML
<policies>
<inbound>
<base />
<return-response>
<set-status code="301" reason="Moved Permanently" />
<set-header name="Location" exists-action="override">
<value>wss://${replace(azurerm_api_management_api.api_v1.service_url, "https://", "")}/api/ws</value>
</set-header>
<set-body />
</return-response>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
XML
}
resource "azurerm_api_management_product" "external" {
product_id = "external"
api_management_name = azurerm_api_management.apim.name
resource_group_name = azurerm_api_management.apim.resource_group_name
display_name = "Some APIs"
subscription_required = true
approval_required = false
published = true
lifecycle {
# Terms are managed manually
ignore_changes = [terms]
}
}
resource "azurerm_api_management_product_api" "api_v1_product" {
for_each = toset([azurerm_api_management_product.external.product_id])
api_name = azurerm_api_management_api.api_v1.name
product_id = each.value
api_management_name = azurerm_api_management_api_version_set.api.api_management_name
resource_group_name = azurerm_api_management_api_version_set.api.resource_group_name
} On AzureRM 3.69.0 the plan works as expected, with no changes in the plan. With Version 3.70.0 and 3.71.0 the aforementioned error appears. |
This bug still appears with version 3.89.0 |
Bug also present with version 3.92.0 |
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. |
Is there an existing issue for this?
Community Note
Terraform Version
1.0.2
AzureRM Provider Version
3.71.0
Affected Resource(s)/Data Source(s)
azurerm_api_management_api_policy
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
module.api-global-policy[0].azurerm_api_management_policy.this[0]: Refreshing state... [id=/subscriptions//resourceGroups/rg-ag-qa01-api-s-01/providers/Microsoft.ApiManagement/service/apim-ag-qa01-api-s-01/policies/policy]
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.
Actual Behaviour
╷
│ Error: parsing "/subscriptions/xxxxxxxxxx/resourceGroups/xxxxxxxx/providers/Microsoft.ApiManagement/service/xxxxxxxxx/apis/xxxxxx/policies/policy": unexpected segment "policies/policy" present at the end of the URI (input "/subscriptions/xxxxxxxxx/resourceGroups/xxxxxxxx/providers/Microsoft.ApiManagement/service/xxxxxxxx/apis/xxxxx/policies/policy")
│
│ with module.api.azurerm_api_management_api_policy.api_policies[0],
│ on .terraform/modules/api/api-template/api-resources.tf line 30, in resource "azurerm_api_management_api_policy" "api_policies":
│ 30: resource "azurerm_api_management_api_policy" "api_policies" {
│
╵
Steps to Reproduce
terraform init - which will use latest version 3.71.0
Important Factoids
No response
References
No response
The text was updated successfully, but these errors were encountered: