Azure API Management API Policy
This page shows how to write Terraform and Azure Resource Manager for API Management API Policy and write them securely.
azurerm_api_management_api_policy (Terraform)
The API Policy in API Management can be configured in Terraform with the resource name azurerm_api_management_api_policy
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_api_management_api_policy" "policy" {
api_name = var.name
api_management_name = var.apim_name
resource_group_name = var.rg_name
xml_content = var.policy_xml
resource "azurerm_api_management_api_policy" "hmi_apim_api_policy" {
api_name = azurerm_api_management_api.hmi_apim_api.name
api_management_name = azurerm_api_management.hmi_apim.name
resource_group_name = azurerm_resource_group.hmi_apim_rg.name
xml_content = file("../template/api-policy.xml")
resource "azurerm_api_management_api_policy" "utility_logicapps_helper" {
resource_group_name = data.azurerm_api_management.eai_apim_instance.resource_group_name
api_management_name = data.azurerm_api_management.eai_apim_instance.name
api_name = azurerm_api_management_api.utility_logicapps_helper.name
resource "azurerm_api_management_api_policy" "this" {
api_management_name = var.api_management_name
api_name = var.api_name
resource_group_name = var.resource_group_name
xml_content = var.xml_content
xml_link = var.xml_link
resource "azurerm_api_management_api_policy" "apim" {
api_name = azurerm_api_management_api.apim.name
api_management_name = data.azurerm_api_management.apim.name
resource_group_name = var.virtual_network_resource_group
xml_content = <<XML
resource "azurerm_api_management_api_policy" "this" {
api_management_name = var.api_management_name
api_name = var.api_name
resource_group_name = var.resource_group_name
xml_content = var.xml_content
xml_link = var.xml_link
resource "azurerm_api_management_api_policy" "example" {
api_name = azurerm_api_management_api.SampleAPI.name
api_management_name = azurerm_api_management_api.SampleAPI.api_management_name
resource_group_name = azurerm_api_management_api.SampleAPI.resource_group_name
xml_content = file("api_policy.xml")
resource "azurerm_api_management_api_policy" "api_management_api_policy" {
api_name = azurerm_api_management_api.api_management_api.name
api_management_name = var.api_management_name
resource_group_name = var.resource_group_name
xml_content = var.policy_xml
resource "azurerm_api_management_api_policy" "api_policy" {
for_each = { for api-policy in var.api-policy : api-policy.api_name => api-policy }
api_name = azurerm_api_management_api.api[each.value.api_name].name
api_management_name = azurerm_api_management_api.api[each.value.api_name].api_management_name
resource_group_name = azurerm_api_management_api.api[each.value.api_name].resource_group_name
resource "azurerm_api_management_api_policy" "example" {
api_name = azurerm_api_management_api.example.name
api_management_name = azurerm_api_management.apim.name
resource_group_name = azurerm_resource_group.rg.name
xml_content = <<XML
Parameters
-
api_management_name
required - string -
api_name
required - string -
id
optional computed - string -
resource_group_name
required - string -
xml_content
optional computed - string -
xml_link
optional - string -
timeouts
single block
Explanation in Terraform Registry
Manages an API Management API Policy
Microsoft.ApiManagement/service/apis/policies (Azure Resource Manager)
The service/apis/policies in Microsoft.ApiManagement can be configured in Azure Resource Manager with the resource name Microsoft.ApiManagement/service/apis/policies
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
apiVersion
required - stringname
required - stringThe identifier of the Policy.
properties
requiredformat
optional - stringFormat of the policyContent.
value
required - stringContents of the Policy as defined by the format.
type
required - string
Frequently asked questions
What is Azure API Management API Policy?
Azure API Management API Policy is a resource for API Management of Microsoft Azure. Settings can be wrote in Terraform.
Where can I find the example code for the Azure API Management API Policy?
For Terraform, the julianpiornoglobant/CoE-API, hmcts/fh-hmi-api-gateway and michaelstephensonuk/IntegrationPlaybook-Samples-AzureAPIM source code examples are useful. See the Terraform Example section for further details.