Skip to content

azurermApiManagementPolicy

Manages a API Management service Policy.

\~> NOTE: This resource will, upon creation, overwrite any existing policy in the API Management service, as there is no feasible way to test whether the policy has been modified from the default. Similarly, when this resource is destroyed, the API Management service will revert to its default policy.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-resources",
  }
);
const azurermApiManagementExample = new azurerm.apiManagement.ApiManagement(
  this,
  "example_1",
  {
    location: azurermResourceGroupExample.location,
    name: "example-apim",
    publisher_email: "pub1@email.com",
    publisher_name: "pub1",
    resource_group_name: azurermResourceGroupExample.name,
    sku_name: "Developer_1",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermApiManagementExample.overrideLogicalId("example");
const azurermApiManagementNamedValueExample =
  new azurerm.apiManagementNamedValue.ApiManagementNamedValue(
    this,
    "example_2",
    {
      api_management_name: azurermApiManagementExample.name,
      display_name: "ExampleProperty",
      name: "example-apimg",
      resource_group_name: azurermResourceGroupExample.name,
      value: "Example Value",
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermApiManagementNamedValueExample.overrideLogicalId("example");
const azurermApiManagementPolicyExample =
  new azurerm.apiManagementPolicy.ApiManagementPolicy(this, "example_3", {
    api_management_id: azurermApiManagementExample.id,
    xml_content: '${file("example.xml")}',
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermApiManagementPolicyExample.overrideLogicalId("example");

Arguments Reference

The following arguments are supported:

  • apiManagementId - (Required) The ID of the API Management service. Changing this forces a new API Management service Policy to be created.

  • xmlContent - (Optional) The XML Content for this Policy as a string. An XML file can be used here with Terraform's file function that is similar to Microsoft's policyFilePath option.

  • xmlLink - (Optional) A link to a Policy XML Document, which must be publicly available.

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

  • id - The ID of the API Management service Policy.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the API Management service Policy.
  • read - (Defaults to 5 minutes) Used when retrieving the API Management service Policy.
  • update - (Defaults to 30 minutes) Used when updating the API Management service Policy.
  • delete - (Defaults to 30 minutes) Used when deleting the API Management service Policy.

Import

API Management service Policys can be imported using the resourceId, e.g.

terraform import azurerm_api_management_policy.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.ApiManagement/service/instance1/policies/policy