Show / Hide Table of Contents

Class Assignment

Configures the specified Policy Definition at the specified Scope. Also, Policy Set Definitions are supported.

Example Usage

using Pulumi;
using Azure = Pulumi.Azure;

class MyStack : Stack
{
public MyStack()
{
    var exampleDefinition = new Azure.Policy.Definition("exampleDefinition", new Azure.Policy.DefinitionArgs
    {
        PolicyType = "Custom",
        Mode = "All",
        DisplayName = "my-policy-definition",
        PolicyRule = @"	{
""if"": {
  ""not"": {
    ""field"": ""location"",
    ""in"": ""[parameters('allowedLocations')]""
  }
},
""then"": {
  ""effect"": ""audit""
}
}
",
        Parameters = @"	{
""allowedLocations"": {
  ""type"": ""Array"",
  ""metadata"": {
    ""description"": ""The list of allowed locations for resources."",
    ""displayName"": ""Allowed locations"",
    ""strongType"": ""location""
  }
}
}
",
    });
    var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new Azure.Core.ResourceGroupArgs
    {
        Location = "West Europe",
    });
    var exampleAssignment = new Azure.Policy.Assignment("exampleAssignment", new Azure.Policy.AssignmentArgs
    {
        Scope = exampleResourceGroup.Id,
        PolicyDefinitionId = exampleDefinition.Id,
        Description = "Policy Assignment created via an Acceptance Test",
        DisplayName = "My Example Policy Assignment",
        Parameters = @"{
""allowedLocations"": {
""value"": [ ""West Europe"" ]
}
}
",
    });
}

}
Inheritance
System.Object
Resource
CustomResource
Assignment
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.Azure.Policy
Assembly: Pulumi.Azure.dll
Syntax
public class Assignment : CustomResource

Constructors

View Source

Assignment(String, AssignmentArgs, CustomResourceOptions)

Create a Assignment resource with the given unique name, arguments, and options.

Declaration
public Assignment(string name, AssignmentArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

AssignmentArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

Description

A description to use for this Policy Assignment. Changing this forces a new resource to be created.

Declaration
public Output<string> Description { get; }
Property Value
Type Description
Output<System.String>
View Source

DisplayName

A friendly display name to use for this Policy Assignment. Changing this forces a new resource to be created.

Declaration
public Output<string> DisplayName { get; }
Property Value
Type Description
Output<System.String>
View Source

Identity

An identity block.

Declaration
public Output<AssignmentIdentity> Identity { get; }
Property Value
Type Description
Output<AssignmentIdentity>
View Source

Location

The Azure location where this policy assignment should exist. This is required when an Identity is assigned. Changing this forces a new resource to be created.

Declaration
public Output<string> Location { get; }
Property Value
Type Description
Output<System.String>
View Source

Name

The name of the Policy Assignment. Changing this forces a new resource to be created.

Declaration
public Output<string> Name { get; }
Property Value
Type Description
Output<System.String>
View Source

NotScopes

A list of the Policy Assignment's excluded scopes. The list must contain Resource IDs (such as Subscriptions e.g. /subscriptions/00000000-0000-0000-000000000000 or Resource Groups e.g./subscriptions/00000000-0000-0000-000000000000/resourceGroups/myResourceGroup).

Declaration
public Output<ImmutableArray<string>> NotScopes { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>
View Source

Parameters

Parameters for the policy definition. This field is a JSON object that maps to the Parameters field from the Policy Definition. Changing this forces a new resource to be created.

Declaration
public Output<string> Parameters { get; }
Property Value
Type Description
Output<System.String>
View Source

PolicyDefinitionId

The ID of the Policy Definition to be applied at the specified Scope.

Declaration
public Output<string> PolicyDefinitionId { get; }
Property Value
Type Description
Output<System.String>
View Source

Scope

The Scope at which the Policy Assignment should be applied, which must be a Resource ID (such as Subscription e.g. /subscriptions/00000000-0000-0000-000000000000 or a Resource Group e.g./subscriptions/00000000-0000-0000-000000000000/resourceGroups/myResourceGroup). Changing this forces a new resource to be created.

Declaration
public Output<string> Scope { get; }
Property Value
Type Description
Output<System.String>

Methods

View Source

Get(String, Input<String>, AssignmentState, CustomResourceOptions)

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

Declaration
public static Assignment Get(string name, Input<string> id, AssignmentState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

AssignmentState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
Assignment
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.