I’m importing APIs into Azure API Management (APIM) using Terraform, as shown below.
The issue:
While all the APIs and their operations defined in the OpenAPI (Swagger) specification are successfully created in APIM, only the APIs themselves are being tracked in the Terraform state file — the operations under these APIs are not managed in the state.
Is this the expected behaviour, or am I missing something?
Why this matters
I need to configure specific backends (either Logic App or Function App) for a few of these operations.
For Terraform to manage these, it needs to know about the API operations.
Here’s the relevant code snippet:
resource "azurerm_api_management_api" "api" {
for_each = local.my_apis
provider = azurerm.hub
name = "${local.api_name}-${each.key}"
resource_group_name = azurerm_api_management_product.abc.resource_group_name
api_management_name = azurerm_api_management_product.abc.api_management_name
revision = "1"
display_name = "${each.value.display_name}"
path = "${each.value.gateway_path}"
protocols = ["https"]
subscription_required = true
oauth2_authorization {
authorization_server_name = local.abc_api_oauth2_provider_name
}
import {
content_format = each.value.api_content_format
content_value = each.value.api_content_value <-- holds the swagger OpenAPI specification content.
}
}
Any guidance or clarification would be greatly appreciated!