We recommend using Azure Native.
Manages an API Management Workspace Policy.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = new azure.core.ResourceGroup("example", {
name: "example-resources",
location: "West Europe",
});
const exampleService = new azure.apimanagement.Service("example", {
name: "example-apimanagement",
location: example.location,
resourceGroupName: example.name,
publisherName: "pub1",
publisherEmail: "pub1@email.com",
skuName: "Premium_1",
});
const exampleWorkspace = new azure.apimanagement.Workspace("example", {
name: "example-workspace",
apiManagementId: exampleService.id,
displayName: "my workspace",
});
const exampleWorkspacePolicy = new azure.apimanagement.WorkspacePolicy("example", {
apiManagementWorkspaceId: exampleWorkspace.id,
xmlContent: `<policies>
<inbound>
<find-and-replace from=\\"abc\\" to=\\"xyz\\" />
</inbound>
</policies>
`,
});
import pulumi
import pulumi_azure as azure
example = azure.core.ResourceGroup("example",
name="example-resources",
location="West Europe")
example_service = azure.apimanagement.Service("example",
name="example-apimanagement",
location=example.location,
resource_group_name=example.name,
publisher_name="pub1",
publisher_email="pub1@email.com",
sku_name="Premium_1")
example_workspace = azure.apimanagement.Workspace("example",
name="example-workspace",
api_management_id=example_service.id,
display_name="my workspace")
example_workspace_policy = azure.apimanagement.WorkspacePolicy("example",
api_management_workspace_id=example_workspace.id,
xml_content="""<policies>
<inbound>
<find-and-replace from=\"abc\" to=\"xyz\" />
</inbound>
</policies>
""")
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/apimanagement"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
Name: pulumi.String("example-resources"),
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleService, err := apimanagement.NewService(ctx, "example", &apimanagement.ServiceArgs{
Name: pulumi.String("example-apimanagement"),
Location: example.Location,
ResourceGroupName: example.Name,
PublisherName: pulumi.String("pub1"),
PublisherEmail: pulumi.String("pub1@email.com"),
SkuName: pulumi.String("Premium_1"),
})
if err != nil {
return err
}
exampleWorkspace, err := apimanagement.NewWorkspace(ctx, "example", &apimanagement.WorkspaceArgs{
Name: pulumi.String("example-workspace"),
ApiManagementId: exampleService.ID(),
DisplayName: pulumi.String("my workspace"),
})
if err != nil {
return err
}
_, err = apimanagement.NewWorkspacePolicy(ctx, "example", &apimanagement.WorkspacePolicyArgs{
ApiManagementWorkspaceId: exampleWorkspace.ID(),
XmlContent: pulumi.String(`<policies>
<inbound>
<find-and-replace from=\"abc\" to=\"xyz\" />
</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 = new Azure.Core.ResourceGroup("example", new()
{
Name = "example-resources",
Location = "West Europe",
});
var exampleService = new Azure.ApiManagement.Service("example", new()
{
Name = "example-apimanagement",
Location = example.Location,
ResourceGroupName = example.Name,
PublisherName = "pub1",
PublisherEmail = "pub1@email.com",
SkuName = "Premium_1",
});
var exampleWorkspace = new Azure.ApiManagement.Workspace("example", new()
{
Name = "example-workspace",
ApiManagementId = exampleService.Id,
DisplayName = "my workspace",
});
var exampleWorkspacePolicy = new Azure.ApiManagement.WorkspacePolicy("example", new()
{
ApiManagementWorkspaceId = exampleWorkspace.Id,
XmlContent = @"<policies>
<inbound>
<find-and-replace from=\""abc\"" to=\""xyz\"" />
</inbound>
</policies>
",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.apimanagement.Service;
import com.pulumi.azure.apimanagement.ServiceArgs;
import com.pulumi.azure.apimanagement.Workspace;
import com.pulumi.azure.apimanagement.WorkspaceArgs;
import com.pulumi.azure.apimanagement.WorkspacePolicy;
import com.pulumi.azure.apimanagement.WorkspacePolicyArgs;
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) {
var example = new ResourceGroup("example", ResourceGroupArgs.builder()
.name("example-resources")
.location("West Europe")
.build());
var exampleService = new Service("exampleService", ServiceArgs.builder()
.name("example-apimanagement")
.location(example.location())
.resourceGroupName(example.name())
.publisherName("pub1")
.publisherEmail("pub1@email.com")
.skuName("Premium_1")
.build());
var exampleWorkspace = new Workspace("exampleWorkspace", WorkspaceArgs.builder()
.name("example-workspace")
.apiManagementId(exampleService.id())
.displayName("my workspace")
.build());
var exampleWorkspacePolicy = new WorkspacePolicy("exampleWorkspacePolicy", WorkspacePolicyArgs.builder()
.apiManagementWorkspaceId(exampleWorkspace.id())
.xmlContent("""
<policies>
<inbound>
<find-and-replace from=\"abc\" to=\"xyz\" />
</inbound>
</policies>
""")
.build());
}
}
resources:
example:
type: azure:core:ResourceGroup
properties:
name: example-resources
location: West Europe
exampleService:
type: azure:apimanagement:Service
name: example
properties:
name: example-apimanagement
location: ${example.location}
resourceGroupName: ${example.name}
publisherName: pub1
publisherEmail: pub1@email.com
skuName: Premium_1
exampleWorkspace:
type: azure:apimanagement:Workspace
name: example
properties:
name: example-workspace
apiManagementId: ${exampleService.id}
displayName: my workspace
exampleWorkspacePolicy:
type: azure:apimanagement:WorkspacePolicy
name: example
properties:
apiManagementWorkspaceId: ${exampleWorkspace.id}
xmlContent: |
<policies>
<inbound>
<find-and-replace from=\"abc\" to=\"xyz\" />
</inbound>
</policies>
API Providers
This resource uses the following Azure API Providers:
Microsoft.ApiManagement- 2024-05-01
Create WorkspacePolicy Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new WorkspacePolicy(name: string, args: WorkspacePolicyArgs, opts?: CustomResourceOptions);@overload
def WorkspacePolicy(resource_name: str,
args: WorkspacePolicyArgs,
opts: Optional[ResourceOptions] = None)
@overload
def WorkspacePolicy(resource_name: str,
opts: Optional[ResourceOptions] = None,
api_management_workspace_id: Optional[str] = None,
xml_content: Optional[str] = None,
xml_link: Optional[str] = None)func NewWorkspacePolicy(ctx *Context, name string, args WorkspacePolicyArgs, opts ...ResourceOption) (*WorkspacePolicy, error)public WorkspacePolicy(string name, WorkspacePolicyArgs args, CustomResourceOptions? opts = null)
public WorkspacePolicy(String name, WorkspacePolicyArgs args)
public WorkspacePolicy(String name, WorkspacePolicyArgs args, CustomResourceOptions options)
type: azure:apimanagement:WorkspacePolicy
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 WorkspacePolicyArgs
- 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 WorkspacePolicyArgs
- 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 WorkspacePolicyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args WorkspacePolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args WorkspacePolicyArgs
- 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 workspacePolicyResource = new Azure.ApiManagement.WorkspacePolicy("workspacePolicyResource", new()
{
ApiManagementWorkspaceId = "string",
XmlContent = "string",
XmlLink = "string",
});
example, err := apimanagement.NewWorkspacePolicy(ctx, "workspacePolicyResource", &apimanagement.WorkspacePolicyArgs{
ApiManagementWorkspaceId: pulumi.String("string"),
XmlContent: pulumi.String("string"),
XmlLink: pulumi.String("string"),
})
var workspacePolicyResource = new WorkspacePolicy("workspacePolicyResource", WorkspacePolicyArgs.builder()
.apiManagementWorkspaceId("string")
.xmlContent("string")
.xmlLink("string")
.build());
workspace_policy_resource = azure.apimanagement.WorkspacePolicy("workspacePolicyResource",
api_management_workspace_id="string",
xml_content="string",
xml_link="string")
const workspacePolicyResource = new azure.apimanagement.WorkspacePolicy("workspacePolicyResource", {
apiManagementWorkspaceId: "string",
xmlContent: "string",
xmlLink: "string",
});
type: azure:apimanagement:WorkspacePolicy
properties:
apiManagementWorkspaceId: string
xmlContent: string
xmlLink: string
WorkspacePolicy Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The WorkspacePolicy resource accepts the following input properties:
- Api
Management stringWorkspace Id - Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
- Xml
Content string - Specifies the API Management Workspace Policy as an XML string.
- Xml
Link string Specifies a publicly accessible URL to a policy XML document.
Note: Exactly one of
xml_contentorxml_linkmust be specified.
- Api
Management stringWorkspace Id - Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
- Xml
Content string - Specifies the API Management Workspace Policy as an XML string.
- Xml
Link string Specifies a publicly accessible URL to a policy XML document.
Note: Exactly one of
xml_contentorxml_linkmust be specified.
- api
Management StringWorkspace Id - Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
- xml
Content String - Specifies the API Management Workspace Policy as an XML string.
- xml
Link String Specifies a publicly accessible URL to a policy XML document.
Note: Exactly one of
xml_contentorxml_linkmust be specified.
- api
Management stringWorkspace Id - Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
- xml
Content string - Specifies the API Management Workspace Policy as an XML string.
- xml
Link string Specifies a publicly accessible URL to a policy XML document.
Note: Exactly one of
xml_contentorxml_linkmust be specified.
- api_
management_ strworkspace_ id - Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
- xml_
content str - Specifies the API Management Workspace Policy as an XML string.
- xml_
link str Specifies a publicly accessible URL to a policy XML document.
Note: Exactly one of
xml_contentorxml_linkmust be specified.
- api
Management StringWorkspace Id - Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
- xml
Content String - Specifies the API Management Workspace Policy as an XML string.
- xml
Link String Specifies a publicly accessible URL to a policy XML document.
Note: Exactly one of
xml_contentorxml_linkmust be specified.
Outputs
All input properties are implicitly available as output properties. Additionally, the WorkspacePolicy 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 WorkspacePolicy Resource
Get an existing WorkspacePolicy 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?: WorkspacePolicyState, opts?: CustomResourceOptions): WorkspacePolicy@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
api_management_workspace_id: Optional[str] = None,
xml_content: Optional[str] = None,
xml_link: Optional[str] = None) -> WorkspacePolicyfunc GetWorkspacePolicy(ctx *Context, name string, id IDInput, state *WorkspacePolicyState, opts ...ResourceOption) (*WorkspacePolicy, error)public static WorkspacePolicy Get(string name, Input<string> id, WorkspacePolicyState? state, CustomResourceOptions? opts = null)public static WorkspacePolicy get(String name, Output<String> id, WorkspacePolicyState state, CustomResourceOptions options)resources: _: type: azure:apimanagement:WorkspacePolicy get: id: ${id}- 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 stringWorkspace Id - Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
- Xml
Content string - Specifies the API Management Workspace Policy as an XML string.
- Xml
Link string Specifies a publicly accessible URL to a policy XML document.
Note: Exactly one of
xml_contentorxml_linkmust be specified.
- Api
Management stringWorkspace Id - Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
- Xml
Content string - Specifies the API Management Workspace Policy as an XML string.
- Xml
Link string Specifies a publicly accessible URL to a policy XML document.
Note: Exactly one of
xml_contentorxml_linkmust be specified.
- api
Management StringWorkspace Id - Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
- xml
Content String - Specifies the API Management Workspace Policy as an XML string.
- xml
Link String Specifies a publicly accessible URL to a policy XML document.
Note: Exactly one of
xml_contentorxml_linkmust be specified.
- api
Management stringWorkspace Id - Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
- xml
Content string - Specifies the API Management Workspace Policy as an XML string.
- xml
Link string Specifies a publicly accessible URL to a policy XML document.
Note: Exactly one of
xml_contentorxml_linkmust be specified.
- api_
management_ strworkspace_ id - Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
- xml_
content str - Specifies the API Management Workspace Policy as an XML string.
- xml_
link str Specifies a publicly accessible URL to a policy XML document.
Note: Exactly one of
xml_contentorxml_linkmust be specified.
- api
Management StringWorkspace Id - Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created.
- xml
Content String - Specifies the API Management Workspace Policy as an XML string.
- xml
Link String Specifies a publicly accessible URL to a policy XML document.
Note: Exactly one of
xml_contentorxml_linkmust be specified.
Import
API Management Workspace Policies can be imported using the resource id, e.g.
$ pulumi import azure:apimanagement/workspacePolicy:WorkspacePolicy example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.ApiManagement/service/service1/workspaces/workspace1
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
azurermTerraform Provider.
