ResourcePolicyAssignmentArgs

data class ResourcePolicyAssignmentArgs(val description: Output<String>? = null, val displayName: Output<String>? = null, val enforce: Output<Boolean>? = null, val identity: Output<ResourcePolicyAssignmentIdentityArgs>? = null, val location: Output<String>? = null, val metadata: Output<String>? = null, val name: Output<String>? = null, val nonComplianceMessages: Output<List<ResourcePolicyAssignmentNonComplianceMessageArgs>>? = null, val notScopes: Output<List<String>>? = null, val overrides: Output<List<ResourcePolicyAssignmentOverrideArgs>>? = null, val parameters: Output<String>? = null, val policyDefinitionId: Output<String>? = null, val resourceId: Output<String>? = null, val resourceSelectors: Output<List<ResourcePolicyAssignmentResourceSelectorArgs>>? = null) : ConvertibleToJava<ResourcePolicyAssignmentArgs>

Manages a Policy Assignment to a Resource.

Example Usage

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 exampleVirtualNetwork = NetworkFunctions.getVirtualNetwork(GetVirtualNetworkArgs.builder()
.name("production")
.resourceGroupName("networking")
.build());
var exampleDefinition = new Definition("exampleDefinition", DefinitionArgs.builder()
.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()
.resourceId(exampleVirtualNetwork.applyValue(getVirtualNetworkResult -> getVirtualNetworkResult.id()))
.policyDefinitionId(exampleDefinition.id())
.build());
}
}

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.

Constructors

Link copied to clipboard
fun ResourcePolicyAssignmentArgs(description: Output<String>? = null, displayName: Output<String>? = null, enforce: Output<Boolean>? = null, identity: Output<ResourcePolicyAssignmentIdentityArgs>? = null, location: Output<String>? = null, metadata: Output<String>? = null, name: Output<String>? = null, nonComplianceMessages: Output<List<ResourcePolicyAssignmentNonComplianceMessageArgs>>? = null, notScopes: Output<List<String>>? = null, overrides: Output<List<ResourcePolicyAssignmentOverrideArgs>>? = null, parameters: Output<String>? = null, policyDefinitionId: Output<String>? = null, resourceId: Output<String>? = null, resourceSelectors: Output<List<ResourcePolicyAssignmentResourceSelectorArgs>>? = null)

Functions

Link copied to clipboard
open override fun toJava(): ResourcePolicyAssignmentArgs

Properties

Link copied to clipboard
val description: Output<String>? = null

A description which should be used for this Policy Assignment.

Link copied to clipboard
val displayName: Output<String>? = null

The Display Name for this Policy Assignment.

Link copied to clipboard
val enforce: Output<Boolean>? = null

Specifies if this Policy should be enforced or not? Defaults to true.

Link copied to clipboard

An identity block as defined below.

Link copied to clipboard
val location: Output<String>? = null

The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created.

Link copied to clipboard
val metadata: Output<String>? = null

A JSON mapping of any Metadata for this Policy.

Link copied to clipboard
val name: Output<String>? = null

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.

Link copied to clipboard

One or more non_compliance_message blocks as defined below.

Link copied to clipboard
val notScopes: Output<List<String>>? = null

Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy.

Link copied to clipboard

One or more overrides blocks as defined below. More detail about overrides and resource_selectors see policy assignment structure

Link copied to clipboard
val parameters: Output<String>? = null

A JSON mapping of any Parameters for this Policy.

Link copied to clipboard
val policyDefinitionId: Output<String>? = null

The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created.

Link copied to clipboard
val resourceId: Output<String>? = null

The ID of the Resource (or Resource Scope) where this should be applied. Changing this forces a new Resource Policy Assignment to be created.

Link copied to clipboard

One or more resource_selectors blocks as defined below to filter polices by resource properties.