import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Manages a Policy Assignment to a Resource. * * ## Example Usage * * ```typescript * 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, * }); * ``` * * ## API Providers * * * This resource uses the following Azure API Providers: * * * `Microsoft.Authorization` - 2022-06-01 * * ## Import * * Resource Policy Assignments can be imported using the `resource id`, e.g. * * ```sh * $ 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`. */ export declare class ResourcePolicyAssignment extends pulumi.CustomResource { /** * Get an existing ResourcePolicyAssignment resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input, state?: ResourcePolicyAssignmentState, opts?: pulumi.CustomResourceOptions): ResourcePolicyAssignment; /** * Returns true if the given object is an instance of ResourcePolicyAssignment. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is ResourcePolicyAssignment; /** * A description which should be used for this Policy Assignment. */ readonly description: pulumi.Output; /** * The Display Name for this Policy Assignment. */ readonly displayName: pulumi.Output; /** * Specifies if this Policy should be enforced or not? Defaults to `true`. */ readonly enforce: pulumi.Output; /** * An `identity` block as defined below. * * > **Note:** The `location` field must also be specified when `identity` is specified. */ readonly identity: pulumi.Output; /** * The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created. */ readonly location: pulumi.Output; /** * A JSON mapping of any Metadata for this Policy. */ readonly metadata: pulumi.Output; /** * 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. */ readonly name: pulumi.Output; /** * One or more `nonComplianceMessage` blocks as defined below. */ readonly nonComplianceMessages: pulumi.Output; /** * Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy. */ readonly notScopes: pulumi.Output; /** * One or more `overrides` blocks as defined below. More detail about `overrides` and `resourceSelectors` see [policy assignment structure](https://learn.microsoft.com/en-us/azure/governance/policy/concepts/assignment-structure) */ readonly overrides: pulumi.Output; /** * A JSON mapping of any Parameters for this Policy. */ readonly parameters: pulumi.Output; /** * The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created. */ readonly policyDefinitionId: pulumi.Output; /** * The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created. * * > **Note:** To create a Policy Assignment at a Management Group use the `azure.management.GroupPolicyAssignment` resource, for a Resource Group use the `azure.core.ResourceGroupPolicyAssignment` and for a Subscription use the `azure.core.SubscriptionPolicyAssignment` resource. */ readonly resourceId: pulumi.Output; /** * One or more `resourceSelectors` blocks as defined below to filter polices by resource properties. */ readonly resourceSelectors: pulumi.Output; /** * Create a ResourcePolicyAssignment resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: ResourcePolicyAssignmentArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering ResourcePolicyAssignment resources. */ export interface ResourcePolicyAssignmentState { /** * A description which should be used for this Policy Assignment. */ description?: pulumi.Input; /** * The Display Name for this Policy Assignment. */ displayName?: pulumi.Input; /** * Specifies if this Policy should be enforced or not? Defaults to `true`. */ enforce?: pulumi.Input; /** * An `identity` block as defined below. * * > **Note:** The `location` field must also be specified when `identity` is specified. */ identity?: pulumi.Input; /** * The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created. */ location?: pulumi.Input; /** * A JSON mapping of any Metadata for this Policy. */ metadata?: pulumi.Input; /** * 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. */ name?: pulumi.Input; /** * One or more `nonComplianceMessage` blocks as defined below. */ nonComplianceMessages?: pulumi.Input[]>; /** * Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy. */ notScopes?: pulumi.Input[]>; /** * One or more `overrides` blocks as defined below. More detail about `overrides` and `resourceSelectors` see [policy assignment structure](https://learn.microsoft.com/en-us/azure/governance/policy/concepts/assignment-structure) */ overrides?: pulumi.Input[]>; /** * A JSON mapping of any Parameters for this Policy. */ parameters?: pulumi.Input; /** * The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created. */ policyDefinitionId?: pulumi.Input; /** * The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created. * * > **Note:** To create a Policy Assignment at a Management Group use the `azure.management.GroupPolicyAssignment` resource, for a Resource Group use the `azure.core.ResourceGroupPolicyAssignment` and for a Subscription use the `azure.core.SubscriptionPolicyAssignment` resource. */ resourceId?: pulumi.Input; /** * One or more `resourceSelectors` blocks as defined below to filter polices by resource properties. */ resourceSelectors?: pulumi.Input[]>; } /** * The set of arguments for constructing a ResourcePolicyAssignment resource. */ export interface ResourcePolicyAssignmentArgs { /** * A description which should be used for this Policy Assignment. */ description?: pulumi.Input; /** * The Display Name for this Policy Assignment. */ displayName?: pulumi.Input; /** * Specifies if this Policy should be enforced or not? Defaults to `true`. */ enforce?: pulumi.Input; /** * An `identity` block as defined below. * * > **Note:** The `location` field must also be specified when `identity` is specified. */ identity?: pulumi.Input; /** * The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created. */ location?: pulumi.Input; /** * A JSON mapping of any Metadata for this Policy. */ metadata?: pulumi.Input; /** * 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. */ name?: pulumi.Input; /** * One or more `nonComplianceMessage` blocks as defined below. */ nonComplianceMessages?: pulumi.Input[]>; /** * Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy. */ notScopes?: pulumi.Input[]>; /** * One or more `overrides` blocks as defined below. More detail about `overrides` and `resourceSelectors` see [policy assignment structure](https://learn.microsoft.com/en-us/azure/governance/policy/concepts/assignment-structure) */ overrides?: pulumi.Input[]>; /** * A JSON mapping of any Parameters for this Policy. */ parameters?: pulumi.Input; /** * The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created. */ policyDefinitionId: pulumi.Input; /** * The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created. * * > **Note:** To create a Policy Assignment at a Management Group use the `azure.management.GroupPolicyAssignment` resource, for a Resource Group use the `azure.core.ResourceGroupPolicyAssignment` and for a Subscription use the `azure.core.SubscriptionPolicyAssignment` resource. */ resourceId: pulumi.Input; /** * One or more `resourceSelectors` blocks as defined below to filter polices by resource properties. */ resourceSelectors?: pulumi.Input[]>; }