1. Packages
  2. Azure Classic
  3. API Docs
  4. apimanagement
  5. ProductPolicy

We recommend using Azure Native.

Azure Classic v5.70.0 published on Wednesday, Mar 27, 2024 by Pulumi

azure.apimanagement.ProductPolicy

Explore with Pulumi AI

azure logo

We recommend using Azure Native.

Azure Classic v5.70.0 published on Wednesday, Mar 27, 2024 by Pulumi

    Manages an API Management Product Policy

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    
    const example = azure.apimanagement.getProduct({
        productId: "my-product",
        apiManagementName: "example-apim",
        resourceGroupName: "search-service",
    });
    const exampleProductPolicy = new azure.apimanagement.ProductPolicy("example", {
        productId: example.then(example => example.productId),
        apiManagementName: example.then(example => example.apiManagementName),
        resourceGroupName: example.then(example => example.resourceGroupName),
        xmlContent: `<policies>
      <inbound>
        <find-and-replace from="xyz" to="abc" />
      </inbound>
    </policies>
    `,
    });
    
    import pulumi
    import pulumi_azure as azure
    
    example = azure.apimanagement.get_product(product_id="my-product",
        api_management_name="example-apim",
        resource_group_name="search-service")
    example_product_policy = azure.apimanagement.ProductPolicy("example",
        product_id=example.product_id,
        api_management_name=example.api_management_name,
        resource_group_name=example.resource_group_name,
        xml_content="""<policies>
      <inbound>
        <find-and-replace from="xyz" to="abc" />
      </inbound>
    </policies>
    """)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/apimanagement"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := apimanagement.LookupProduct(ctx, &apimanagement.LookupProductArgs{
    			ProductId:         "my-product",
    			ApiManagementName: "example-apim",
    			ResourceGroupName: "search-service",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = apimanagement.NewProductPolicy(ctx, "example", &apimanagement.ProductPolicyArgs{
    			ProductId:         pulumi.String(example.ProductId),
    			ApiManagementName: pulumi.String(example.ApiManagementName),
    			ResourceGroupName: pulumi.String(example.ResourceGroupName),
    			XmlContent: pulumi.String(`<policies>
      <inbound>
        <find-and-replace from="xyz" to="abc" />
      </inbound>
    </policies>
    `),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Azure = Pulumi.Azure;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Azure.ApiManagement.GetProduct.Invoke(new()
        {
            ProductId = "my-product",
            ApiManagementName = "example-apim",
            ResourceGroupName = "search-service",
        });
    
        var exampleProductPolicy = new Azure.ApiManagement.ProductPolicy("example", new()
        {
            ProductId = example.Apply(getProductResult => getProductResult.ProductId),
            ApiManagementName = example.Apply(getProductResult => getProductResult.ApiManagementName),
            ResourceGroupName = example.Apply(getProductResult => getProductResult.ResourceGroupName),
            XmlContent = @"<policies>
      <inbound>
        <find-and-replace from=""xyz"" to=""abc"" />
      </inbound>
    </policies>
    ",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azure.apimanagement.ApimanagementFunctions;
    import com.pulumi.azure.apimanagement.inputs.GetProductArgs;
    import com.pulumi.azure.apimanagement.ProductPolicy;
    import com.pulumi.azure.apimanagement.ProductPolicyArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var example = ApimanagementFunctions.getProduct(GetProductArgs.builder()
                .productId("my-product")
                .apiManagementName("example-apim")
                .resourceGroupName("search-service")
                .build());
    
            var exampleProductPolicy = new ProductPolicy("exampleProductPolicy", ProductPolicyArgs.builder()        
                .productId(example.applyValue(getProductResult -> getProductResult.productId()))
                .apiManagementName(example.applyValue(getProductResult -> getProductResult.apiManagementName()))
                .resourceGroupName(example.applyValue(getProductResult -> getProductResult.resourceGroupName()))
                .xmlContent("""
    <policies>
      <inbound>
        <find-and-replace from="xyz" to="abc" />
      </inbound>
    </policies>
                """)
                .build());
    
        }
    }
    
    resources:
      exampleProductPolicy:
        type: azure:apimanagement:ProductPolicy
        name: example
        properties:
          productId: ${example.productId}
          apiManagementName: ${example.apiManagementName}
          resourceGroupName: ${example.resourceGroupName}
          xmlContent: |
            <policies>
              <inbound>
                <find-and-replace from="xyz" to="abc" />
              </inbound>
            </policies>        
    variables:
      example:
        fn::invoke:
          Function: azure:apimanagement:getProduct
          Arguments:
            productId: my-product
            apiManagementName: example-apim
            resourceGroupName: search-service
    

    Create ProductPolicy Resource

    new ProductPolicy(name: string, args: ProductPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def ProductPolicy(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      api_management_name: Optional[str] = None,
                      product_id: Optional[str] = None,
                      resource_group_name: Optional[str] = None,
                      xml_content: Optional[str] = None,
                      xml_link: Optional[str] = None)
    @overload
    def ProductPolicy(resource_name: str,
                      args: ProductPolicyArgs,
                      opts: Optional[ResourceOptions] = None)
    func NewProductPolicy(ctx *Context, name string, args ProductPolicyArgs, opts ...ResourceOption) (*ProductPolicy, error)
    public ProductPolicy(string name, ProductPolicyArgs args, CustomResourceOptions? opts = null)
    public ProductPolicy(String name, ProductPolicyArgs args)
    public ProductPolicy(String name, ProductPolicyArgs args, CustomResourceOptions options)
    
    type: azure:apimanagement:ProductPolicy
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args ProductPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args ProductPolicyArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args ProductPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ProductPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ProductPolicyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    ProductPolicy Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The ProductPolicy resource accepts the following input properties:

    ApiManagementName string
    The name of the API Management Service. Changing this forces a new resource to be created.
    ProductId string
    The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
    ResourceGroupName string
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    XmlContent string
    The XML Content for this Policy.
    XmlLink string
    A link to a Policy XML Document, which must be publicly available.
    ApiManagementName string
    The name of the API Management Service. Changing this forces a new resource to be created.
    ProductId string
    The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
    ResourceGroupName string
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    XmlContent string
    The XML Content for this Policy.
    XmlLink string
    A link to a Policy XML Document, which must be publicly available.
    apiManagementName String
    The name of the API Management Service. Changing this forces a new resource to be created.
    productId String
    The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
    resourceGroupName String
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xmlContent String
    The XML Content for this Policy.
    xmlLink String
    A link to a Policy XML Document, which must be publicly available.
    apiManagementName string
    The name of the API Management Service. Changing this forces a new resource to be created.
    productId string
    The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
    resourceGroupName string
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xmlContent string
    The XML Content for this Policy.
    xmlLink string
    A link to a Policy XML Document, which must be publicly available.
    api_management_name str
    The name of the API Management Service. Changing this forces a new resource to be created.
    product_id str
    The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
    resource_group_name str
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xml_content str
    The XML Content for this Policy.
    xml_link str
    A link to a Policy XML Document, which must be publicly available.
    apiManagementName String
    The name of the API Management Service. Changing this forces a new resource to be created.
    productId String
    The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
    resourceGroupName String
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xmlContent String
    The XML Content for this Policy.
    xmlLink String
    A link to a Policy XML Document, which must be publicly available.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ProductPolicy resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing ProductPolicy Resource

    Get an existing ProductPolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: ProductPolicyState, opts?: CustomResourceOptions): ProductPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            api_management_name: Optional[str] = None,
            product_id: Optional[str] = None,
            resource_group_name: Optional[str] = None,
            xml_content: Optional[str] = None,
            xml_link: Optional[str] = None) -> ProductPolicy
    func GetProductPolicy(ctx *Context, name string, id IDInput, state *ProductPolicyState, opts ...ResourceOption) (*ProductPolicy, error)
    public static ProductPolicy Get(string name, Input<string> id, ProductPolicyState? state, CustomResourceOptions? opts = null)
    public static ProductPolicy get(String name, Output<String> id, ProductPolicyState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    ApiManagementName string
    The name of the API Management Service. Changing this forces a new resource to be created.
    ProductId string
    The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
    ResourceGroupName string
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    XmlContent string
    The XML Content for this Policy.
    XmlLink string
    A link to a Policy XML Document, which must be publicly available.
    ApiManagementName string
    The name of the API Management Service. Changing this forces a new resource to be created.
    ProductId string
    The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
    ResourceGroupName string
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    XmlContent string
    The XML Content for this Policy.
    XmlLink string
    A link to a Policy XML Document, which must be publicly available.
    apiManagementName String
    The name of the API Management Service. Changing this forces a new resource to be created.
    productId String
    The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
    resourceGroupName String
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xmlContent String
    The XML Content for this Policy.
    xmlLink String
    A link to a Policy XML Document, which must be publicly available.
    apiManagementName string
    The name of the API Management Service. Changing this forces a new resource to be created.
    productId string
    The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
    resourceGroupName string
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xmlContent string
    The XML Content for this Policy.
    xmlLink string
    A link to a Policy XML Document, which must be publicly available.
    api_management_name str
    The name of the API Management Service. Changing this forces a new resource to be created.
    product_id str
    The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
    resource_group_name str
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xml_content str
    The XML Content for this Policy.
    xml_link str
    A link to a Policy XML Document, which must be publicly available.
    apiManagementName String
    The name of the API Management Service. Changing this forces a new resource to be created.
    productId String
    The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
    resourceGroupName String
    The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
    xmlContent String
    The XML Content for this Policy.
    xmlLink String
    A link to a Policy XML Document, which must be publicly available.

    Import

    API Management Product Policy can be imported using the resource id, e.g.

    $ pulumi import azure:apimanagement/productPolicy:ProductPolicy example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.ApiManagement/service/service1/products/product1
    

    Package Details

    Repository
    Azure Classic pulumi/pulumi-azure
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the azurerm Terraform Provider.
    azure logo

    We recommend using Azure Native.

    Azure Classic v5.70.0 published on Wednesday, Mar 27, 2024 by Pulumi