0
votes
data "azurerm_api_management_api" "example" {
  api_name            = "my-api"
  api_management_name = "example-apim"
  resource_group_name = "search-service"
}

resource "azurerm_api_management_api_policy" "example" {
  api_name            = data.azurerm_api_management_api.example.name
  api_management_name = data.azurerm_api_management_api.example.api_management_name
  resource_group_name = data.azurerm_api_management_api.example.resource_group_name

  xml_content = <<XML
<policies>
  <inbound>
    <find-and-replace from="xyz" to="abc" />
  </inbound>
</policies>
XML
}

We have option to add policies in api group level (i mean micro-services level), not sure how to add the policy for individual api level ?, Note: portal UI provides that option for adding individual api

https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/api_management_api_policy

given examples are api group level, could not find one for individual api level

enter image description here

1

1 Answers

0
votes

Found a way, there is something called azurerm_api_management_api_operation_policy

https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/api_management_api_operation_policy

operation id is something you can get it from api-spec file, which uniquely identifies individual apis