We recommend using Azure Native.
azure.core.ResourcePolicyAssignment
Explore with Pulumi AI
Manages a Policy Assignment to a Resource.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = azure.network.getVirtualNetwork({
name: "production",
resourceGroupName: "networking",
});
const exampleDefinition = new azure.policy.Definition("example", {
name: "only-deploy-in-westeurope",
policyType: "Custom",
mode: "All",
displayName: "my-policy-definition",
policyRule: ` {
"if": {
"not": {
"field": "location",
"equals": "westeurope"
}
},
"then": {
"effect": "Deny"
}
}
`,
});
const exampleResourcePolicyAssignment = new azure.core.ResourcePolicyAssignment("example", {
name: "example-policy-assignment",
resourceId: example.then(example => example.id),
policyDefinitionId: exampleDefinition.id,
});
import pulumi
import pulumi_azure as azure
example = azure.network.get_virtual_network(name="production",
resource_group_name="networking")
example_definition = azure.policy.Definition("example",
name="only-deploy-in-westeurope",
policy_type="Custom",
mode="All",
display_name="my-policy-definition",
policy_rule=""" {
"if": {
"not": {
"field": "location",
"equals": "westeurope"
}
},
"then": {
"effect": "Deny"
}
}
""")
example_resource_policy_assignment = azure.core.ResourcePolicyAssignment("example",
name="example-policy-assignment",
resource_id=example.id,
policy_definition_id=example_definition.id)
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/network"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/policy"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := network.LookupVirtualNetwork(ctx, &network.LookupVirtualNetworkArgs{
Name: "production",
ResourceGroupName: "networking",
}, nil)
if err != nil {
return err
}
exampleDefinition, err := policy.NewDefinition(ctx, "example", &policy.DefinitionArgs{
Name: pulumi.String("only-deploy-in-westeurope"),
PolicyType: pulumi.String("Custom"),
Mode: pulumi.String("All"),
DisplayName: pulumi.String("my-policy-definition"),
PolicyRule: pulumi.String(` {
"if": {
"not": {
"field": "location",
"equals": "westeurope"
}
},
"then": {
"effect": "Deny"
}
}
`),
})
if err != nil {
return err
}
_, err = core.NewResourcePolicyAssignment(ctx, "example", &core.ResourcePolicyAssignmentArgs{
Name: pulumi.String("example-policy-assignment"),
ResourceId: pulumi.String(example.Id),
PolicyDefinitionId: exampleDefinition.ID(),
})
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.Network.GetVirtualNetwork.Invoke(new()
{
Name = "production",
ResourceGroupName = "networking",
});
var exampleDefinition = new Azure.Policy.Definition("example", new()
{
Name = "only-deploy-in-westeurope",
PolicyType = "Custom",
Mode = "All",
DisplayName = "my-policy-definition",
PolicyRule = @" {
""if"": {
""not"": {
""field"": ""location"",
""equals"": ""westeurope""
}
},
""then"": {
""effect"": ""Deny""
}
}
",
});
var exampleResourcePolicyAssignment = new Azure.Core.ResourcePolicyAssignment("example", new()
{
Name = "example-policy-assignment",
ResourceId = example.Apply(getVirtualNetworkResult => getVirtualNetworkResult.Id),
PolicyDefinitionId = exampleDefinition.Id,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.network.NetworkFunctions;
import com.pulumi.azure.network.inputs.GetVirtualNetworkArgs;
import com.pulumi.azure.policy.Definition;
import com.pulumi.azure.policy.DefinitionArgs;
import com.pulumi.azure.core.ResourcePolicyAssignment;
import com.pulumi.azure.core.ResourcePolicyAssignmentArgs;
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 = NetworkFunctions.getVirtualNetwork(GetVirtualNetworkArgs.builder()
.name("production")
.resourceGroupName("networking")
.build());
var exampleDefinition = new Definition("exampleDefinition", DefinitionArgs.builder()
.name("only-deploy-in-westeurope")
.policyType("Custom")
.mode("All")
.displayName("my-policy-definition")
.policyRule("""
{
"if": {
"not": {
"field": "location",
"equals": "westeurope"
}
},
"then": {
"effect": "Deny"
}
}
""")
.build());
var exampleResourcePolicyAssignment = new ResourcePolicyAssignment("exampleResourcePolicyAssignment", ResourcePolicyAssignmentArgs.builder()
.name("example-policy-assignment")
.resourceId(example.applyValue(getVirtualNetworkResult -> getVirtualNetworkResult.id()))
.policyDefinitionId(exampleDefinition.id())
.build());
}
}
resources:
exampleDefinition:
type: azure:policy:Definition
name: example
properties:
name: only-deploy-in-westeurope
policyType: Custom
mode: All
displayName: my-policy-definition
policyRule: |2
{
"if": {
"not": {
"field": "location",
"equals": "westeurope"
}
},
"then": {
"effect": "Deny"
}
}
exampleResourcePolicyAssignment:
type: azure:core:ResourcePolicyAssignment
name: example
properties:
name: example-policy-assignment
resourceId: ${example.id}
policyDefinitionId: ${exampleDefinition.id}
variables:
example:
fn::invoke:
Function: azure:network:getVirtualNetwork
Arguments:
name: production
resourceGroupName: networking
Create ResourcePolicyAssignment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ResourcePolicyAssignment(name: string, args: ResourcePolicyAssignmentArgs, opts?: CustomResourceOptions);
@overload
def ResourcePolicyAssignment(resource_name: str,
args: ResourcePolicyAssignmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def ResourcePolicyAssignment(resource_name: str,
opts: Optional[ResourceOptions] = None,
policy_definition_id: Optional[str] = None,
resource_id: Optional[str] = None,
name: Optional[str] = None,
identity: Optional[ResourcePolicyAssignmentIdentityArgs] = None,
location: Optional[str] = None,
metadata: Optional[str] = None,
description: Optional[str] = None,
non_compliance_messages: Optional[Sequence[ResourcePolicyAssignmentNonComplianceMessageArgs]] = None,
not_scopes: Optional[Sequence[str]] = None,
overrides: Optional[Sequence[ResourcePolicyAssignmentOverrideArgs]] = None,
parameters: Optional[str] = None,
enforce: Optional[bool] = None,
display_name: Optional[str] = None,
resource_selectors: Optional[Sequence[ResourcePolicyAssignmentResourceSelectorArgs]] = None)
func NewResourcePolicyAssignment(ctx *Context, name string, args ResourcePolicyAssignmentArgs, opts ...ResourceOption) (*ResourcePolicyAssignment, error)
public ResourcePolicyAssignment(string name, ResourcePolicyAssignmentArgs args, CustomResourceOptions? opts = null)
public ResourcePolicyAssignment(String name, ResourcePolicyAssignmentArgs args)
public ResourcePolicyAssignment(String name, ResourcePolicyAssignmentArgs args, CustomResourceOptions options)
type: azure:core:ResourcePolicyAssignment
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 ResourcePolicyAssignmentArgs
- 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 ResourcePolicyAssignmentArgs
- 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 ResourcePolicyAssignmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ResourcePolicyAssignmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ResourcePolicyAssignmentArgs
- 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 resourcePolicyAssignmentResource = new Azure.Core.ResourcePolicyAssignment("resourcePolicyAssignmentResource", new()
{
PolicyDefinitionId = "string",
ResourceId = "string",
Name = "string",
Identity = new Azure.Core.Inputs.ResourcePolicyAssignmentIdentityArgs
{
Type = "string",
IdentityIds = new[]
{
"string",
},
PrincipalId = "string",
TenantId = "string",
},
Location = "string",
Metadata = "string",
Description = "string",
NonComplianceMessages = new[]
{
new Azure.Core.Inputs.ResourcePolicyAssignmentNonComplianceMessageArgs
{
Content = "string",
PolicyDefinitionReferenceId = "string",
},
},
NotScopes = new[]
{
"string",
},
Overrides = new[]
{
new Azure.Core.Inputs.ResourcePolicyAssignmentOverrideArgs
{
Value = "string",
Selectors = new[]
{
new Azure.Core.Inputs.ResourcePolicyAssignmentOverrideSelectorArgs
{
Ins = new[]
{
"string",
},
Kind = "string",
NotIns = new[]
{
"string",
},
},
},
},
},
Parameters = "string",
Enforce = false,
DisplayName = "string",
ResourceSelectors = new[]
{
new Azure.Core.Inputs.ResourcePolicyAssignmentResourceSelectorArgs
{
Selectors = new[]
{
new Azure.Core.Inputs.ResourcePolicyAssignmentResourceSelectorSelectorArgs
{
Kind = "string",
Ins = new[]
{
"string",
},
NotIns = new[]
{
"string",
},
},
},
Name = "string",
},
},
});
example, err := core.NewResourcePolicyAssignment(ctx, "resourcePolicyAssignmentResource", &core.ResourcePolicyAssignmentArgs{
PolicyDefinitionId: pulumi.String("string"),
ResourceId: pulumi.String("string"),
Name: pulumi.String("string"),
Identity: &core.ResourcePolicyAssignmentIdentityArgs{
Type: pulumi.String("string"),
IdentityIds: pulumi.StringArray{
pulumi.String("string"),
},
PrincipalId: pulumi.String("string"),
TenantId: pulumi.String("string"),
},
Location: pulumi.String("string"),
Metadata: pulumi.String("string"),
Description: pulumi.String("string"),
NonComplianceMessages: core.ResourcePolicyAssignmentNonComplianceMessageArray{
&core.ResourcePolicyAssignmentNonComplianceMessageArgs{
Content: pulumi.String("string"),
PolicyDefinitionReferenceId: pulumi.String("string"),
},
},
NotScopes: pulumi.StringArray{
pulumi.String("string"),
},
Overrides: core.ResourcePolicyAssignmentOverrideArray{
&core.ResourcePolicyAssignmentOverrideArgs{
Value: pulumi.String("string"),
Selectors: core.ResourcePolicyAssignmentOverrideSelectorArray{
&core.ResourcePolicyAssignmentOverrideSelectorArgs{
Ins: pulumi.StringArray{
pulumi.String("string"),
},
Kind: pulumi.String("string"),
NotIns: pulumi.StringArray{
pulumi.String("string"),
},
},
},
},
},
Parameters: pulumi.String("string"),
Enforce: pulumi.Bool(false),
DisplayName: pulumi.String("string"),
ResourceSelectors: core.ResourcePolicyAssignmentResourceSelectorArray{
&core.ResourcePolicyAssignmentResourceSelectorArgs{
Selectors: core.ResourcePolicyAssignmentResourceSelectorSelectorArray{
&core.ResourcePolicyAssignmentResourceSelectorSelectorArgs{
Kind: pulumi.String("string"),
Ins: pulumi.StringArray{
pulumi.String("string"),
},
NotIns: pulumi.StringArray{
pulumi.String("string"),
},
},
},
Name: pulumi.String("string"),
},
},
})
var resourcePolicyAssignmentResource = new ResourcePolicyAssignment("resourcePolicyAssignmentResource", ResourcePolicyAssignmentArgs.builder()
.policyDefinitionId("string")
.resourceId("string")
.name("string")
.identity(ResourcePolicyAssignmentIdentityArgs.builder()
.type("string")
.identityIds("string")
.principalId("string")
.tenantId("string")
.build())
.location("string")
.metadata("string")
.description("string")
.nonComplianceMessages(ResourcePolicyAssignmentNonComplianceMessageArgs.builder()
.content("string")
.policyDefinitionReferenceId("string")
.build())
.notScopes("string")
.overrides(ResourcePolicyAssignmentOverrideArgs.builder()
.value("string")
.selectors(ResourcePolicyAssignmentOverrideSelectorArgs.builder()
.ins("string")
.kind("string")
.notIns("string")
.build())
.build())
.parameters("string")
.enforce(false)
.displayName("string")
.resourceSelectors(ResourcePolicyAssignmentResourceSelectorArgs.builder()
.selectors(ResourcePolicyAssignmentResourceSelectorSelectorArgs.builder()
.kind("string")
.ins("string")
.notIns("string")
.build())
.name("string")
.build())
.build());
resource_policy_assignment_resource = azure.core.ResourcePolicyAssignment("resourcePolicyAssignmentResource",
policy_definition_id="string",
resource_id="string",
name="string",
identity={
"type": "string",
"identity_ids": ["string"],
"principal_id": "string",
"tenant_id": "string",
},
location="string",
metadata="string",
description="string",
non_compliance_messages=[{
"content": "string",
"policy_definition_reference_id": "string",
}],
not_scopes=["string"],
overrides=[{
"value": "string",
"selectors": [{
"ins": ["string"],
"kind": "string",
"not_ins": ["string"],
}],
}],
parameters="string",
enforce=False,
display_name="string",
resource_selectors=[{
"selectors": [{
"kind": "string",
"ins": ["string"],
"not_ins": ["string"],
}],
"name": "string",
}])
const resourcePolicyAssignmentResource = new azure.core.ResourcePolicyAssignment("resourcePolicyAssignmentResource", {
policyDefinitionId: "string",
resourceId: "string",
name: "string",
identity: {
type: "string",
identityIds: ["string"],
principalId: "string",
tenantId: "string",
},
location: "string",
metadata: "string",
description: "string",
nonComplianceMessages: [{
content: "string",
policyDefinitionReferenceId: "string",
}],
notScopes: ["string"],
overrides: [{
value: "string",
selectors: [{
ins: ["string"],
kind: "string",
notIns: ["string"],
}],
}],
parameters: "string",
enforce: false,
displayName: "string",
resourceSelectors: [{
selectors: [{
kind: "string",
ins: ["string"],
notIns: ["string"],
}],
name: "string",
}],
});
type: azure:core:ResourcePolicyAssignment
properties:
description: string
displayName: string
enforce: false
identity:
identityIds:
- string
principalId: string
tenantId: string
type: string
location: string
metadata: string
name: string
nonComplianceMessages:
- content: string
policyDefinitionReferenceId: string
notScopes:
- string
overrides:
- selectors:
- ins:
- string
kind: string
notIns:
- string
value: string
parameters: string
policyDefinitionId: string
resourceId: string
resourceSelectors:
- name: string
selectors:
- ins:
- string
kind: string
notIns:
- string
ResourcePolicyAssignment 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 ResourcePolicyAssignment resource accepts the following input properties:
- Policy
Definition stringId - The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created.
- Resource
Id string The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created.
To create a Policy Assignment at a Management Group use the
azure.management.GroupPolicyAssignment
resource, for a Resource Group use theazure.core.ResourceGroupPolicyAssignment
and for a Subscription use theazure.core.SubscriptionPolicyAssignment
resource.- Description string
- A description which should be used for this Policy Assignment.
- Display
Name string - The Display Name for this Policy Assignment.
- Enforce bool
- Specifies if this Policy should be enforced or not? Defaults to
true
. - Identity
Resource
Policy Assignment Identity An
identity
block as defined below.Note: The
location
field must also be specified whenidentity
is specified.- Location string
- The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created.
- Metadata string
- A JSON mapping of any Metadata for this Policy.
- Name string
- The name which should be used for this Policy Assignment. Changing this forces a new Resource Policy Assignment to be created. Cannot exceed 64 characters in length.
- Non
Compliance List<ResourceMessages Policy Assignment Non Compliance Message> - One or more
non_compliance_message
blocks as defined below. - Not
Scopes List<string> - Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy.
- Overrides
List<Resource
Policy Assignment Override> - One or more
overrides
blocks as defined below. More detail aboutoverrides
andresource_selectors
see policy assignment structure - Parameters string
- A JSON mapping of any Parameters for this Policy.
- Resource
Selectors List<ResourcePolicy Assignment Resource Selector> - One or more
resource_selectors
blocks as defined below to filter polices by resource properties.
- Policy
Definition stringId - The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created.
- Resource
Id string The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created.
To create a Policy Assignment at a Management Group use the
azure.management.GroupPolicyAssignment
resource, for a Resource Group use theazure.core.ResourceGroupPolicyAssignment
and for a Subscription use theazure.core.SubscriptionPolicyAssignment
resource.- Description string
- A description which should be used for this Policy Assignment.
- Display
Name string - The Display Name for this Policy Assignment.
- Enforce bool
- Specifies if this Policy should be enforced or not? Defaults to
true
. - Identity
Resource
Policy Assignment Identity Args An
identity
block as defined below.Note: The
location
field must also be specified whenidentity
is specified.- Location string
- The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created.
- Metadata string
- A JSON mapping of any Metadata for this Policy.
- Name string
- The name which should be used for this Policy Assignment. Changing this forces a new Resource Policy Assignment to be created. Cannot exceed 64 characters in length.
- Non
Compliance []ResourceMessages Policy Assignment Non Compliance Message Args - One or more
non_compliance_message
blocks as defined below. - Not
Scopes []string - Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy.
- Overrides
[]Resource
Policy Assignment Override Args - One or more
overrides
blocks as defined below. More detail aboutoverrides
andresource_selectors
see policy assignment structure - Parameters string
- A JSON mapping of any Parameters for this Policy.
- Resource
Selectors []ResourcePolicy Assignment Resource Selector Args - One or more
resource_selectors
blocks as defined below to filter polices by resource properties.
- policy
Definition StringId - The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created.
- resource
Id String The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created.
To create a Policy Assignment at a Management Group use the
azure.management.GroupPolicyAssignment
resource, for a Resource Group use theazure.core.ResourceGroupPolicyAssignment
and for a Subscription use theazure.core.SubscriptionPolicyAssignment
resource.- description String
- A description which should be used for this Policy Assignment.
- display
Name String - The Display Name for this Policy Assignment.
- enforce Boolean
- Specifies if this Policy should be enforced or not? Defaults to
true
. - identity
Resource
Policy Assignment Identity An
identity
block as defined below.Note: The
location
field must also be specified whenidentity
is specified.- location String
- The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created.
- metadata String
- A JSON mapping of any Metadata for this Policy.
- name String
- The name which should be used for this Policy Assignment. Changing this forces a new Resource Policy Assignment to be created. Cannot exceed 64 characters in length.
- non
Compliance List<ResourceMessages Policy Assignment Non Compliance Message> - One or more
non_compliance_message
blocks as defined below. - not
Scopes List<String> - Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy.
- overrides
List<Resource
Policy Assignment Override> - One or more
overrides
blocks as defined below. More detail aboutoverrides
andresource_selectors
see policy assignment structure - parameters String
- A JSON mapping of any Parameters for this Policy.
- resource
Selectors List<ResourcePolicy Assignment Resource Selector> - One or more
resource_selectors
blocks as defined below to filter polices by resource properties.
- policy
Definition stringId - The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created.
- resource
Id string The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created.
To create a Policy Assignment at a Management Group use the
azure.management.GroupPolicyAssignment
resource, for a Resource Group use theazure.core.ResourceGroupPolicyAssignment
and for a Subscription use theazure.core.SubscriptionPolicyAssignment
resource.- description string
- A description which should be used for this Policy Assignment.
- display
Name string - The Display Name for this Policy Assignment.
- enforce boolean
- Specifies if this Policy should be enforced or not? Defaults to
true
. - identity
Resource
Policy Assignment Identity An
identity
block as defined below.Note: The
location
field must also be specified whenidentity
is specified.- location string
- The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created.
- metadata string
- A JSON mapping of any Metadata for this Policy.
- name string
- The name which should be used for this Policy Assignment. Changing this forces a new Resource Policy Assignment to be created. Cannot exceed 64 characters in length.
- non
Compliance ResourceMessages Policy Assignment Non Compliance Message[] - One or more
non_compliance_message
blocks as defined below. - not
Scopes string[] - Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy.
- overrides
Resource
Policy Assignment Override[] - One or more
overrides
blocks as defined below. More detail aboutoverrides
andresource_selectors
see policy assignment structure - parameters string
- A JSON mapping of any Parameters for this Policy.
- resource
Selectors ResourcePolicy Assignment Resource Selector[] - One or more
resource_selectors
blocks as defined below to filter polices by resource properties.
- policy_
definition_ strid - The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created.
- resource_
id str The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created.
To create a Policy Assignment at a Management Group use the
azure.management.GroupPolicyAssignment
resource, for a Resource Group use theazure.core.ResourceGroupPolicyAssignment
and for a Subscription use theazure.core.SubscriptionPolicyAssignment
resource.- description str
- A description which should be used for this Policy Assignment.
- display_
name str - The Display Name for this Policy Assignment.
- enforce bool
- Specifies if this Policy should be enforced or not? Defaults to
true
. - identity
Resource
Policy Assignment Identity Args An
identity
block as defined below.Note: The
location
field must also be specified whenidentity
is specified.- location str
- The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created.
- metadata str
- A JSON mapping of any Metadata for this Policy.
- name str
- The name which should be used for this Policy Assignment. Changing this forces a new Resource Policy Assignment to be created. Cannot exceed 64 characters in length.
- non_
compliance_ Sequence[Resourcemessages Policy Assignment Non Compliance Message Args] - One or more
non_compliance_message
blocks as defined below. - not_
scopes Sequence[str] - Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy.
- overrides
Sequence[Resource
Policy Assignment Override Args] - One or more
overrides
blocks as defined below. More detail aboutoverrides
andresource_selectors
see policy assignment structure - parameters str
- A JSON mapping of any Parameters for this Policy.
- resource_
selectors Sequence[ResourcePolicy Assignment Resource Selector Args] - One or more
resource_selectors
blocks as defined below to filter polices by resource properties.
- policy
Definition StringId - The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created.
- resource
Id String The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created.
To create a Policy Assignment at a Management Group use the
azure.management.GroupPolicyAssignment
resource, for a Resource Group use theazure.core.ResourceGroupPolicyAssignment
and for a Subscription use theazure.core.SubscriptionPolicyAssignment
resource.- description String
- A description which should be used for this Policy Assignment.
- display
Name String - The Display Name for this Policy Assignment.
- enforce Boolean
- Specifies if this Policy should be enforced or not? Defaults to
true
. - identity Property Map
An
identity
block as defined below.Note: The
location
field must also be specified whenidentity
is specified.- location String
- The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created.
- metadata String
- A JSON mapping of any Metadata for this Policy.
- name String
- The name which should be used for this Policy Assignment. Changing this forces a new Resource Policy Assignment to be created. Cannot exceed 64 characters in length.
- non
Compliance List<Property Map>Messages - One or more
non_compliance_message
blocks as defined below. - not
Scopes List<String> - Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy.
- overrides List<Property Map>
- One or more
overrides
blocks as defined below. More detail aboutoverrides
andresource_selectors
see policy assignment structure - parameters String
- A JSON mapping of any Parameters for this Policy.
- resource
Selectors List<Property Map> - One or more
resource_selectors
blocks as defined below to filter polices by resource properties.
Outputs
All input properties are implicitly available as output properties. Additionally, the ResourcePolicyAssignment 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 ResourcePolicyAssignment Resource
Get an existing ResourcePolicyAssignment 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?: ResourcePolicyAssignmentState, opts?: CustomResourceOptions): ResourcePolicyAssignment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
description: Optional[str] = None,
display_name: Optional[str] = None,
enforce: Optional[bool] = None,
identity: Optional[ResourcePolicyAssignmentIdentityArgs] = None,
location: Optional[str] = None,
metadata: Optional[str] = None,
name: Optional[str] = None,
non_compliance_messages: Optional[Sequence[ResourcePolicyAssignmentNonComplianceMessageArgs]] = None,
not_scopes: Optional[Sequence[str]] = None,
overrides: Optional[Sequence[ResourcePolicyAssignmentOverrideArgs]] = None,
parameters: Optional[str] = None,
policy_definition_id: Optional[str] = None,
resource_id: Optional[str] = None,
resource_selectors: Optional[Sequence[ResourcePolicyAssignmentResourceSelectorArgs]] = None) -> ResourcePolicyAssignment
func GetResourcePolicyAssignment(ctx *Context, name string, id IDInput, state *ResourcePolicyAssignmentState, opts ...ResourceOption) (*ResourcePolicyAssignment, error)
public static ResourcePolicyAssignment Get(string name, Input<string> id, ResourcePolicyAssignmentState? state, CustomResourceOptions? opts = null)
public static ResourcePolicyAssignment get(String name, Output<String> id, ResourcePolicyAssignmentState 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.
- Description string
- A description which should be used for this Policy Assignment.
- Display
Name string - The Display Name for this Policy Assignment.
- Enforce bool
- Specifies if this Policy should be enforced or not? Defaults to
true
. - Identity
Resource
Policy Assignment Identity An
identity
block as defined below.Note: The
location
field must also be specified whenidentity
is specified.- Location string
- The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created.
- Metadata string
- A JSON mapping of any Metadata for this Policy.
- Name string
- The name which should be used for this Policy Assignment. Changing this forces a new Resource Policy Assignment to be created. Cannot exceed 64 characters in length.
- Non
Compliance List<ResourceMessages Policy Assignment Non Compliance Message> - One or more
non_compliance_message
blocks as defined below. - Not
Scopes List<string> - Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy.
- Overrides
List<Resource
Policy Assignment Override> - One or more
overrides
blocks as defined below. More detail aboutoverrides
andresource_selectors
see policy assignment structure - Parameters string
- A JSON mapping of any Parameters for this Policy.
- Policy
Definition stringId - The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created.
- Resource
Id string The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created.
To create a Policy Assignment at a Management Group use the
azure.management.GroupPolicyAssignment
resource, for a Resource Group use theazure.core.ResourceGroupPolicyAssignment
and for a Subscription use theazure.core.SubscriptionPolicyAssignment
resource.- Resource
Selectors List<ResourcePolicy Assignment Resource Selector> - One or more
resource_selectors
blocks as defined below to filter polices by resource properties.
- Description string
- A description which should be used for this Policy Assignment.
- Display
Name string - The Display Name for this Policy Assignment.
- Enforce bool
- Specifies if this Policy should be enforced or not? Defaults to
true
. - Identity
Resource
Policy Assignment Identity Args An
identity
block as defined below.Note: The
location
field must also be specified whenidentity
is specified.- Location string
- The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created.
- Metadata string
- A JSON mapping of any Metadata for this Policy.
- Name string
- The name which should be used for this Policy Assignment. Changing this forces a new Resource Policy Assignment to be created. Cannot exceed 64 characters in length.
- Non
Compliance []ResourceMessages Policy Assignment Non Compliance Message Args - One or more
non_compliance_message
blocks as defined below. - Not
Scopes []string - Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy.
- Overrides
[]Resource
Policy Assignment Override Args - One or more
overrides
blocks as defined below. More detail aboutoverrides
andresource_selectors
see policy assignment structure - Parameters string
- A JSON mapping of any Parameters for this Policy.
- Policy
Definition stringId - The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created.
- Resource
Id string The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created.
To create a Policy Assignment at a Management Group use the
azure.management.GroupPolicyAssignment
resource, for a Resource Group use theazure.core.ResourceGroupPolicyAssignment
and for a Subscription use theazure.core.SubscriptionPolicyAssignment
resource.- Resource
Selectors []ResourcePolicy Assignment Resource Selector Args - One or more
resource_selectors
blocks as defined below to filter polices by resource properties.
- description String
- A description which should be used for this Policy Assignment.
- display
Name String - The Display Name for this Policy Assignment.
- enforce Boolean
- Specifies if this Policy should be enforced or not? Defaults to
true
. - identity
Resource
Policy Assignment Identity An
identity
block as defined below.Note: The
location
field must also be specified whenidentity
is specified.- location String
- The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created.
- metadata String
- A JSON mapping of any Metadata for this Policy.
- name String
- The name which should be used for this Policy Assignment. Changing this forces a new Resource Policy Assignment to be created. Cannot exceed 64 characters in length.
- non
Compliance List<ResourceMessages Policy Assignment Non Compliance Message> - One or more
non_compliance_message
blocks as defined below. - not
Scopes List<String> - Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy.
- overrides
List<Resource
Policy Assignment Override> - One or more
overrides
blocks as defined below. More detail aboutoverrides
andresource_selectors
see policy assignment structure - parameters String
- A JSON mapping of any Parameters for this Policy.
- policy
Definition StringId - The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created.
- resource
Id String The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created.
To create a Policy Assignment at a Management Group use the
azure.management.GroupPolicyAssignment
resource, for a Resource Group use theazure.core.ResourceGroupPolicyAssignment
and for a Subscription use theazure.core.SubscriptionPolicyAssignment
resource.- resource
Selectors List<ResourcePolicy Assignment Resource Selector> - One or more
resource_selectors
blocks as defined below to filter polices by resource properties.
- description string
- A description which should be used for this Policy Assignment.
- display
Name string - The Display Name for this Policy Assignment.
- enforce boolean
- Specifies if this Policy should be enforced or not? Defaults to
true
. - identity
Resource
Policy Assignment Identity An
identity
block as defined below.Note: The
location
field must also be specified whenidentity
is specified.- location string
- The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created.
- metadata string
- A JSON mapping of any Metadata for this Policy.
- name string
- The name which should be used for this Policy Assignment. Changing this forces a new Resource Policy Assignment to be created. Cannot exceed 64 characters in length.
- non
Compliance ResourceMessages Policy Assignment Non Compliance Message[] - One or more
non_compliance_message
blocks as defined below. - not
Scopes string[] - Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy.
- overrides
Resource
Policy Assignment Override[] - One or more
overrides
blocks as defined below. More detail aboutoverrides
andresource_selectors
see policy assignment structure - parameters string
- A JSON mapping of any Parameters for this Policy.
- policy
Definition stringId - The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created.
- resource
Id string The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created.
To create a Policy Assignment at a Management Group use the
azure.management.GroupPolicyAssignment
resource, for a Resource Group use theazure.core.ResourceGroupPolicyAssignment
and for a Subscription use theazure.core.SubscriptionPolicyAssignment
resource.- resource
Selectors ResourcePolicy Assignment Resource Selector[] - One or more
resource_selectors
blocks as defined below to filter polices by resource properties.
- description str
- A description which should be used for this Policy Assignment.
- display_
name str - The Display Name for this Policy Assignment.
- enforce bool
- Specifies if this Policy should be enforced or not? Defaults to
true
. - identity
Resource
Policy Assignment Identity Args An
identity
block as defined below.Note: The
location
field must also be specified whenidentity
is specified.- location str
- The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created.
- metadata str
- A JSON mapping of any Metadata for this Policy.
- name str
- The name which should be used for this Policy Assignment. Changing this forces a new Resource Policy Assignment to be created. Cannot exceed 64 characters in length.
- non_
compliance_ Sequence[Resourcemessages Policy Assignment Non Compliance Message Args] - One or more
non_compliance_message
blocks as defined below. - not_
scopes Sequence[str] - Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy.
- overrides
Sequence[Resource
Policy Assignment Override Args] - One or more
overrides
blocks as defined below. More detail aboutoverrides
andresource_selectors
see policy assignment structure - parameters str
- A JSON mapping of any Parameters for this Policy.
- policy_
definition_ strid - The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created.
- resource_
id str The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created.
To create a Policy Assignment at a Management Group use the
azure.management.GroupPolicyAssignment
resource, for a Resource Group use theazure.core.ResourceGroupPolicyAssignment
and for a Subscription use theazure.core.SubscriptionPolicyAssignment
resource.- resource_
selectors Sequence[ResourcePolicy Assignment Resource Selector Args] - One or more
resource_selectors
blocks as defined below to filter polices by resource properties.
- description String
- A description which should be used for this Policy Assignment.
- display
Name String - The Display Name for this Policy Assignment.
- enforce Boolean
- Specifies if this Policy should be enforced or not? Defaults to
true
. - identity Property Map
An
identity
block as defined below.Note: The
location
field must also be specified whenidentity
is specified.- location String
- The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created.
- metadata String
- A JSON mapping of any Metadata for this Policy.
- name String
- The name which should be used for this Policy Assignment. Changing this forces a new Resource Policy Assignment to be created. Cannot exceed 64 characters in length.
- non
Compliance List<Property Map>Messages - One or more
non_compliance_message
blocks as defined below. - not
Scopes List<String> - Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy.
- overrides List<Property Map>
- One or more
overrides
blocks as defined below. More detail aboutoverrides
andresource_selectors
see policy assignment structure - parameters String
- A JSON mapping of any Parameters for this Policy.
- policy
Definition StringId - The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created.
- resource
Id String The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created.
To create a Policy Assignment at a Management Group use the
azure.management.GroupPolicyAssignment
resource, for a Resource Group use theazure.core.ResourceGroupPolicyAssignment
and for a Subscription use theazure.core.SubscriptionPolicyAssignment
resource.- resource
Selectors List<Property Map> - One or more
resource_selectors
blocks as defined below to filter polices by resource properties.
Supporting Types
ResourcePolicyAssignmentIdentity, ResourcePolicyAssignmentIdentityArgs
- Type string
- The Type of Managed Identity which should be added to this Policy Definition. Possible values are
SystemAssigned
andUserAssigned
. - Identity
Ids List<string> A list of User Managed Identity IDs which should be assigned to the Policy Definition.
NOTE: This is required when
type
is set toUserAssigned
.- Principal
Id string - The Principal ID of the Policy Assignment for this Resource.
- Tenant
Id string - The Tenant ID of the Policy Assignment for this Resource.
- Type string
- The Type of Managed Identity which should be added to this Policy Definition. Possible values are
SystemAssigned
andUserAssigned
. - Identity
Ids []string A list of User Managed Identity IDs which should be assigned to the Policy Definition.
NOTE: This is required when
type
is set toUserAssigned
.- Principal
Id string - The Principal ID of the Policy Assignment for this Resource.
- Tenant
Id string - The Tenant ID of the Policy Assignment for this Resource.
- type String
- The Type of Managed Identity which should be added to this Policy Definition. Possible values are
SystemAssigned
andUserAssigned
. - identity
Ids List<String> A list of User Managed Identity IDs which should be assigned to the Policy Definition.
NOTE: This is required when
type
is set toUserAssigned
.- principal
Id String - The Principal ID of the Policy Assignment for this Resource.
- tenant
Id String - The Tenant ID of the Policy Assignment for this Resource.
- type string
- The Type of Managed Identity which should be added to this Policy Definition. Possible values are
SystemAssigned
andUserAssigned
. - identity
Ids string[] A list of User Managed Identity IDs which should be assigned to the Policy Definition.
NOTE: This is required when
type
is set toUserAssigned
.- principal
Id string - The Principal ID of the Policy Assignment for this Resource.
- tenant
Id string - The Tenant ID of the Policy Assignment for this Resource.
- type str
- The Type of Managed Identity which should be added to this Policy Definition. Possible values are
SystemAssigned
andUserAssigned
. - identity_
ids Sequence[str] A list of User Managed Identity IDs which should be assigned to the Policy Definition.
NOTE: This is required when
type
is set toUserAssigned
.- principal_
id str - The Principal ID of the Policy Assignment for this Resource.
- tenant_
id str - The Tenant ID of the Policy Assignment for this Resource.
- type String
- The Type of Managed Identity which should be added to this Policy Definition. Possible values are
SystemAssigned
andUserAssigned
. - identity
Ids List<String> A list of User Managed Identity IDs which should be assigned to the Policy Definition.
NOTE: This is required when
type
is set toUserAssigned
.- principal
Id String - The Principal ID of the Policy Assignment for this Resource.
- tenant
Id String - The Tenant ID of the Policy Assignment for this Resource.
ResourcePolicyAssignmentNonComplianceMessage, ResourcePolicyAssignmentNonComplianceMessageArgs
- Content string
- The non-compliance message text. When assigning policy sets (initiatives), unless
policy_definition_reference_id
is specified then this message will be the default for all policies. - Policy
Definition stringReference Id - When assigning policy sets (initiatives), this is the ID of the policy definition that the non-compliance message applies to.
- Content string
- The non-compliance message text. When assigning policy sets (initiatives), unless
policy_definition_reference_id
is specified then this message will be the default for all policies. - Policy
Definition stringReference Id - When assigning policy sets (initiatives), this is the ID of the policy definition that the non-compliance message applies to.
- content String
- The non-compliance message text. When assigning policy sets (initiatives), unless
policy_definition_reference_id
is specified then this message will be the default for all policies. - policy
Definition StringReference Id - When assigning policy sets (initiatives), this is the ID of the policy definition that the non-compliance message applies to.
- content string
- The non-compliance message text. When assigning policy sets (initiatives), unless
policy_definition_reference_id
is specified then this message will be the default for all policies. - policy
Definition stringReference Id - When assigning policy sets (initiatives), this is the ID of the policy definition that the non-compliance message applies to.
- content str
- The non-compliance message text. When assigning policy sets (initiatives), unless
policy_definition_reference_id
is specified then this message will be the default for all policies. - policy_
definition_ strreference_ id - When assigning policy sets (initiatives), this is the ID of the policy definition that the non-compliance message applies to.
- content String
- The non-compliance message text. When assigning policy sets (initiatives), unless
policy_definition_reference_id
is specified then this message will be the default for all policies. - policy
Definition StringReference Id - When assigning policy sets (initiatives), this is the ID of the policy definition that the non-compliance message applies to.
ResourcePolicyAssignmentOverride, ResourcePolicyAssignmentOverrideArgs
- Value string
- Specifies the value to override the policy property. Possible values for
policyEffect
override listed policy effects. - Selectors
List<Resource
Policy Assignment Override Selector> - One or more
override_selector
block as defined below.
- Value string
- Specifies the value to override the policy property. Possible values for
policyEffect
override listed policy effects. - Selectors
[]Resource
Policy Assignment Override Selector - One or more
override_selector
block as defined below.
- value String
- Specifies the value to override the policy property. Possible values for
policyEffect
override listed policy effects. - selectors
List<Resource
Policy Assignment Override Selector> - One or more
override_selector
block as defined below.
- value string
- Specifies the value to override the policy property. Possible values for
policyEffect
override listed policy effects. - selectors
Resource
Policy Assignment Override Selector[] - One or more
override_selector
block as defined below.
- value str
- Specifies the value to override the policy property. Possible values for
policyEffect
override listed policy effects. - selectors
Sequence[Resource
Policy Assignment Override Selector] - One or more
override_selector
block as defined below.
- value String
- Specifies the value to override the policy property. Possible values for
policyEffect
override listed policy effects. - selectors List<Property Map>
- One or more
override_selector
block as defined below.
ResourcePolicyAssignmentOverrideSelector, ResourcePolicyAssignmentOverrideSelectorArgs
ResourcePolicyAssignmentResourceSelector, ResourcePolicyAssignmentResourceSelectorArgs
- Selectors
List<Resource
Policy Assignment Resource Selector Selector> - One or more
resource_selector
block as defined below. - Name string
- Specifies a name for the resource selector.
- Selectors
[]Resource
Policy Assignment Resource Selector Selector - One or more
resource_selector
block as defined below. - Name string
- Specifies a name for the resource selector.
- selectors
List<Resource
Policy Assignment Resource Selector Selector> - One or more
resource_selector
block as defined below. - name String
- Specifies a name for the resource selector.
- selectors
Resource
Policy Assignment Resource Selector Selector[] - One or more
resource_selector
block as defined below. - name string
- Specifies a name for the resource selector.
- selectors
Sequence[Resource
Policy Assignment Resource Selector Selector] - One or more
resource_selector
block as defined below. - name str
- Specifies a name for the resource selector.
- selectors List<Property Map>
- One or more
resource_selector
block as defined below. - name String
- Specifies a name for the resource selector.
ResourcePolicyAssignmentResourceSelectorSelector, ResourcePolicyAssignmentResourceSelectorSelectorArgs
Import
Resource Policy Assignments can be imported using the resource id
, e.g.
$ pulumi import azure:core/resourcePolicyAssignment:ResourcePolicyAssignment example "{resource}/providers/Microsoft.Authorization/policyAssignments/assignment1"
where {resource}
is a Resource ID in the form /subscriptions/00000000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/virtualNetworks/network1
.
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.