We recommend using Azure Native.
azure.apimanagement.ProductPolicy
Explore with Pulumi AI
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/v6/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
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ProductPolicy(name: string, args: ProductPolicyArgs, opts?: CustomResourceOptions);
@overload
def ProductPolicy(resource_name: str,
args: ProductPolicyArgs,
opts: Optional[ResourceOptions] = None)
@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)
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.
Parameters
- 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.
Constructor example
The following reference example uses placeholder values for all input properties.
var productPolicyResource = new Azure.ApiManagement.ProductPolicy("productPolicyResource", new()
{
ApiManagementName = "string",
ProductId = "string",
ResourceGroupName = "string",
XmlContent = "string",
XmlLink = "string",
});
example, err := apimanagement.NewProductPolicy(ctx, "productPolicyResource", &apimanagement.ProductPolicyArgs{
ApiManagementName: pulumi.String("string"),
ProductId: pulumi.String("string"),
ResourceGroupName: pulumi.String("string"),
XmlContent: pulumi.String("string"),
XmlLink: pulumi.String("string"),
})
var productPolicyResource = new ProductPolicy("productPolicyResource", ProductPolicyArgs.builder()
.apiManagementName("string")
.productId("string")
.resourceGroupName("string")
.xmlContent("string")
.xmlLink("string")
.build());
product_policy_resource = azure.apimanagement.ProductPolicy("productPolicyResource",
api_management_name="string",
product_id="string",
resource_group_name="string",
xml_content="string",
xml_link="string")
const productPolicyResource = new azure.apimanagement.ProductPolicy("productPolicyResource", {
apiManagementName: "string",
productId: "string",
resourceGroupName: "string",
xmlContent: "string",
xmlLink: "string",
});
type: azure:apimanagement:ProductPolicy
properties:
apiManagementName: string
productId: string
resourceGroupName: string
xmlContent: string
xmlLink: string
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:
- Api
Management stringName - The name of the API Management Service. Changing this forces a new resource to be created.
- Product
Id string - The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
- Resource
Group stringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- Xml
Content string - The XML Content for this Policy.
- Xml
Link string - A link to a Policy XML Document, which must be publicly available.
- Api
Management stringName - The name of the API Management Service. Changing this forces a new resource to be created.
- Product
Id string - The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
- Resource
Group stringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- Xml
Content string - The XML Content for this Policy.
- Xml
Link string - A link to a Policy XML Document, which must be publicly available.
- api
Management StringName - The name of the API Management Service. Changing this forces a new resource to be created.
- product
Id String - The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
- resource
Group StringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- xml
Content String - The XML Content for this Policy.
- xml
Link String - A link to a Policy XML Document, which must be publicly available.
- api
Management stringName - The name of the API Management Service. Changing this forces a new resource to be created.
- product
Id string - The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
- resource
Group stringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- xml
Content string - The XML Content for this Policy.
- xml
Link string - A link to a Policy XML Document, which must be publicly available.
- api_
management_ strname - 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_ strname - 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.
- api
Management StringName - The name of the API Management Service. Changing this forces a new resource to be created.
- product
Id String - The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
- resource
Group StringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- xml
Content String - The XML Content for this Policy.
- xml
Link 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.
- Api
Management stringName - The name of the API Management Service. Changing this forces a new resource to be created.
- Product
Id string - The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
- Resource
Group stringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- Xml
Content string - The XML Content for this Policy.
- Xml
Link string - A link to a Policy XML Document, which must be publicly available.
- Api
Management stringName - The name of the API Management Service. Changing this forces a new resource to be created.
- Product
Id string - The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
- Resource
Group stringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- Xml
Content string - The XML Content for this Policy.
- Xml
Link string - A link to a Policy XML Document, which must be publicly available.
- api
Management StringName - The name of the API Management Service. Changing this forces a new resource to be created.
- product
Id String - The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
- resource
Group StringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- xml
Content String - The XML Content for this Policy.
- xml
Link String - A link to a Policy XML Document, which must be publicly available.
- api
Management stringName - The name of the API Management Service. Changing this forces a new resource to be created.
- product
Id string - The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
- resource
Group stringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- xml
Content string - The XML Content for this Policy.
- xml
Link string - A link to a Policy XML Document, which must be publicly available.
- api_
management_ strname - 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_ strname - 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.
- api
Management StringName - The name of the API Management Service. Changing this forces a new resource to be created.
- product
Id String - The ID of the API Management Product within the API Management Service. Changing this forces a new resource to be created.
- resource
Group StringName - The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
- xml
Content String - The XML Content for this Policy.
- xml
Link 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
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurerm
Terraform Provider.