Closed ron-foreman closed 8 months ago
Hi @ron-foreman thanks for opening this issue. Unfortunately, I could not reproduce the issue with tf config and repro steps below. Please let me know if I missed anything crucial.
Step1: Create a azurerm_api_management_api
with the following tf config.
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.92.0"
}
}
}
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-0311"
location = "eastus"
}
resource "azurerm_api_management" "test" {
name = "acctestAM-0311"
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_api" "test" {
name = "acctestapi-0311"
resource_group_name = azurerm_resource_group.test.name
api_management_name = azurerm_api_management.test.name
display_name = "api1"
path = "api1"
protocols = ["https"]
revision = "1"
}
resource "azurerm_api_management_api_policy" "api_policies" {
api_name = azurerm_api_management_api.test.name
resource_group_name = azurerm_api_management.test.resource_group_name
api_management_name =azurerm_api_management.test.name
xml_content = <<XML
<policies>
<inbound>
<find-and-replace from="xyz" to="abc" />
</inbound>
</policies>
XML
}
Step2: Import the azurerm_api_management_api_policy
created by the above config with command terraform import azurerm_api_management_api_policy.api_policies /subscriptions/xxx/resourceGroups/acctestRG-0311/providers/Microsoft.ApiManagement/service/acctestAM-0311/apis/acctestapi-0311
Actual:
It is worth mentioning that per the Terraform documentation, the command to import azurerm_api_management_api_policy
does not include /policies/policy
.
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.
Is there an existing issue for this?
Community Note
Terraform Version
1.7.0
AzureRM Provider Version
3.92.0
Affected Resource(s)/Data Source(s)
azurerm_api_management_api_policy
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
module.apim.azurerm_api_management_api_policy.apim_api_policy: Import prepared!
Prepared azurerm_api_management_api_operation for import
Import successful!
The resources that were imported are shown above. These resources are now in your Terraform state and will henceforth be managed by Terraform.
Actual Behaviour
╷ │ Error: parsing "/subscriptions/.../resourceGroups/.../providers/Microsoft.ApiManagement/service/.../apis/.../policies/papi/apis/.../policies/policy") │ │ ╵
Steps to Reproduce
terraform import azurerm_api_management_api_policy.apim_api_policy
Important Factoids
No response
References
This error keeps coming up
Issue 23095
Issue 23036