PolicySetDefinition
Manages a policy set definition.
NOTE: Policy set definitions (also known as policy initiatives) do not take effect until they are assigned to a scope using a Policy Set Assignment.
Example Usage
using Pulumi;
using Azure = Pulumi.Azure;
class MyStack : Stack
{
public MyStack()
{
var example = new Azure.Policy.PolicySetDefinition("example", new Azure.Policy.PolicySetDefinitionArgs
{
DisplayName = "Test Policy Set",
Parameters = @" {
""allowedLocations"": {
""type"": ""Array"",
""metadata"": {
""description"": ""The list of allowed locations for resources."",
""displayName"": ""Allowed locations"",
""strongType"": ""location""
}
}
}
",
PolicyDefinitions = @" [
{
""parameters"": {
""listOfAllowedLocations"": {
""value"": ""[parameters('allowedLocations')]""
}
},
""policyDefinitionId"": ""/providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988""
}
]
",
PolicyType = "Custom",
});
}
}
package main
import (
"fmt"
"github.com/pulumi/pulumi-azure/sdk/v3/go/azure/policy"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err = policy.NewPolicySetDefinition(ctx, "example", &policy.PolicySetDefinitionArgs{
DisplayName: pulumi.String("Test Policy Set"),
Parameters: pulumi.String(fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v%v", " {\n", " \"allowedLocations\": {\n", " \"type\": \"Array\",\n", " \"metadata\": {\n", " \"description\": \"The list of allowed locations for resources.\",\n", " \"displayName\": \"Allowed locations\",\n", " \"strongType\": \"location\"\n", " }\n", " }\n", " }\n", "\n")),
PolicyDefinitions: pulumi.String(fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v%v", " [\n", " {\n", " \"parameters\": {\n", " \"listOfAllowedLocations\": {\n", " \"value\": \"[parameters('allowedLocations')]\"\n", " }\n", " },\n", " \"policyDefinitionId\": \"/providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988\"\n", " }\n", " ]\n", "\n")),
PolicyType: pulumi.String("Custom"),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_azure as azure
example = azure.policy.PolicySetDefinition("example",
display_name="Test Policy Set",
parameters=""" {
"allowedLocations": {
"type": "Array",
"metadata": {
"description": "The list of allowed locations for resources.",
"displayName": "Allowed locations",
"strongType": "location"
}
}
}
""",
policy_definitions=""" [
{
"parameters": {
"listOfAllowedLocations": {
"value": "[parameters('allowedLocations')]"
}
},
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988"
}
]
""",
policy_type="Custom")import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = new azure.policy.PolicySetDefinition("example", {
displayName: "Test Policy Set",
parameters: ` {
"allowedLocations": {
"type": "Array",
"metadata": {
"description": "The list of allowed locations for resources.",
"displayName": "Allowed locations",
"strongType": "location"
}
}
}
`,
policyDefinitions: ` [
{
"parameters": {
"listOfAllowedLocations": {
"value": "[parameters('allowedLocations')]"
}
},
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988"
}
]
`,
policyType: "Custom",
});Create a PolicySetDefinition Resource
new PolicySetDefinition(name: string, args: PolicySetDefinitionArgs, opts?: CustomResourceOptions);def PolicySetDefinition(resource_name, opts=None, description=None, display_name=None, management_group_id=None, metadata=None, name=None, parameters=None, policy_definitions=None, policy_type=None, __props__=None);func NewPolicySetDefinition(ctx *Context, name string, args PolicySetDefinitionArgs, opts ...ResourceOption) (*PolicySetDefinition, error)public PolicySetDefinition(string name, PolicySetDefinitionArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args PolicySetDefinitionArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args PolicySetDefinitionArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args PolicySetDefinitionArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
PolicySetDefinition Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The PolicySetDefinition resource accepts the following input properties:
- Display
Name string The display name of the policy set definition.
- Policy
Type string The policy set type. Possible values are
BuiltInorCustom. Changing this forces a new resource to be created.- Description string
The description of the policy set definition.
- Management
Group stringId The ID of the Management Group where this policy should be defined. Changing this forces a new resource to be created.
- Metadata string
The metadata for the policy set definition. This is a json object representing additional metadata that should be stored with the policy definition.
- Name string
The name of the policy set definition. Changing this forces a new resource to be created.
- Parameters string
Parameters for the policy set definition. This field is a json object that allows you to parameterize your policy definition.
- Policy
Definitions string The policy definitions for the policy set definition. This is a json object representing the bundled policy definitions.
- Display
Name string The display name of the policy set definition.
- Policy
Type string The policy set type. Possible values are
BuiltInorCustom. Changing this forces a new resource to be created.- Description string
The description of the policy set definition.
- Management
Group stringId The ID of the Management Group where this policy should be defined. Changing this forces a new resource to be created.
- Metadata string
The metadata for the policy set definition. This is a json object representing additional metadata that should be stored with the policy definition.
- Name string
The name of the policy set definition. Changing this forces a new resource to be created.
- Parameters string
Parameters for the policy set definition. This field is a json object that allows you to parameterize your policy definition.
- Policy
Definitions string The policy definitions for the policy set definition. This is a json object representing the bundled policy definitions.
- display
Name string The display name of the policy set definition.
- policy
Type string The policy set type. Possible values are
BuiltInorCustom. Changing this forces a new resource to be created.- description string
The description of the policy set definition.
- management
Group stringId The ID of the Management Group where this policy should be defined. Changing this forces a new resource to be created.
- metadata string
The metadata for the policy set definition. This is a json object representing additional metadata that should be stored with the policy definition.
- name string
The name of the policy set definition. Changing this forces a new resource to be created.
- parameters string
Parameters for the policy set definition. This field is a json object that allows you to parameterize your policy definition.
- policy
Definitions string The policy definitions for the policy set definition. This is a json object representing the bundled policy definitions.
- display_
name str The display name of the policy set definition.
- policy_
type str The policy set type. Possible values are
BuiltInorCustom. Changing this forces a new resource to be created.- description str
The description of the policy set definition.
- management_
group_ strid The ID of the Management Group where this policy should be defined. Changing this forces a new resource to be created.
- metadata str
The metadata for the policy set definition. This is a json object representing additional metadata that should be stored with the policy definition.
- name str
The name of the policy set definition. Changing this forces a new resource to be created.
- parameters str
Parameters for the policy set definition. This field is a json object that allows you to parameterize your policy definition.
- policy_
definitions str The policy definitions for the policy set definition. This is a json object representing the bundled policy definitions.
Outputs
All input properties are implicitly available as output properties. Additionally, the PolicySetDefinition resource produces the following output properties:
Look up an Existing PolicySetDefinition Resource
Get an existing PolicySetDefinition 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?: PolicySetDefinitionState, opts?: CustomResourceOptions): PolicySetDefinitionstatic get(resource_name, id, opts=None, description=None, display_name=None, management_group_id=None, metadata=None, name=None, parameters=None, policy_definitions=None, policy_type=None, __props__=None);func GetPolicySetDefinition(ctx *Context, name string, id IDInput, state *PolicySetDefinitionState, opts ...ResourceOption) (*PolicySetDefinition, error)public static PolicySetDefinition Get(string name, Input<string> id, PolicySetDefinitionState? state, CustomResourceOptions? opts = null)- 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.
The following state arguments are supported:
- Description string
The description of the policy set definition.
- Display
Name string The display name of the policy set definition.
- Management
Group stringId The ID of the Management Group where this policy should be defined. Changing this forces a new resource to be created.
- Metadata string
The metadata for the policy set definition. This is a json object representing additional metadata that should be stored with the policy definition.
- Name string
The name of the policy set definition. Changing this forces a new resource to be created.
- Parameters string
Parameters for the policy set definition. This field is a json object that allows you to parameterize your policy definition.
- Policy
Definitions string The policy definitions for the policy set definition. This is a json object representing the bundled policy definitions.
- Policy
Type string The policy set type. Possible values are
BuiltInorCustom. Changing this forces a new resource to be created.
- Description string
The description of the policy set definition.
- Display
Name string The display name of the policy set definition.
- Management
Group stringId The ID of the Management Group where this policy should be defined. Changing this forces a new resource to be created.
- Metadata string
The metadata for the policy set definition. This is a json object representing additional metadata that should be stored with the policy definition.
- Name string
The name of the policy set definition. Changing this forces a new resource to be created.
- Parameters string
Parameters for the policy set definition. This field is a json object that allows you to parameterize your policy definition.
- Policy
Definitions string The policy definitions for the policy set definition. This is a json object representing the bundled policy definitions.
- Policy
Type string The policy set type. Possible values are
BuiltInorCustom. Changing this forces a new resource to be created.
- description string
The description of the policy set definition.
- display
Name string The display name of the policy set definition.
- management
Group stringId The ID of the Management Group where this policy should be defined. Changing this forces a new resource to be created.
- metadata string
The metadata for the policy set definition. This is a json object representing additional metadata that should be stored with the policy definition.
- name string
The name of the policy set definition. Changing this forces a new resource to be created.
- parameters string
Parameters for the policy set definition. This field is a json object that allows you to parameterize your policy definition.
- policy
Definitions string The policy definitions for the policy set definition. This is a json object representing the bundled policy definitions.
- policy
Type string The policy set type. Possible values are
BuiltInorCustom. Changing this forces a new resource to be created.
- description str
The description of the policy set definition.
- display_
name str The display name of the policy set definition.
- management_
group_ strid The ID of the Management Group where this policy should be defined. Changing this forces a new resource to be created.
- metadata str
The metadata for the policy set definition. This is a json object representing additional metadata that should be stored with the policy definition.
- name str
The name of the policy set definition. Changing this forces a new resource to be created.
- parameters str
Parameters for the policy set definition. This field is a json object that allows you to parameterize your policy definition.
- policy_
definitions str The policy definitions for the policy set definition. This is a json object representing the bundled policy definitions.
- policy_
type str The policy set type. Possible values are
BuiltInorCustom. Changing this forces a new resource to be created.
Package Details
- Repository
- https://github.com/pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurermTerraform Provider.