All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.azure.core.ResourceGroupPolicyAssignment Maven / Gradle / Ivy

// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

package com.pulumi.azure.core;

import com.pulumi.azure.Utilities;
import com.pulumi.azure.core.ResourceGroupPolicyAssignmentArgs;
import com.pulumi.azure.core.inputs.ResourceGroupPolicyAssignmentState;
import com.pulumi.azure.core.outputs.ResourceGroupPolicyAssignmentIdentity;
import com.pulumi.azure.core.outputs.ResourceGroupPolicyAssignmentNonComplianceMessage;
import com.pulumi.azure.core.outputs.ResourceGroupPolicyAssignmentOverride;
import com.pulumi.azure.core.outputs.ResourceGroupPolicyAssignmentResourceSelector;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.Boolean;
import java.lang.String;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * Manages a Resource Group Policy Assignment.
 * 
 * ## Example Usage
 * 
 * <!--Start PulumiCodeChooser -->
 * 
 * {@code
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.policy.Definition;
 * import com.pulumi.azure.policy.DefinitionArgs;
 * import com.pulumi.azure.core.ResourceGroupPolicyAssignment;
 * import com.pulumi.azure.core.ResourceGroupPolicyAssignmentArgs;
 * 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) {
 *         var example = new ResourceGroup("example", ResourceGroupArgs.builder()
 *             .name("example-resources")
 *             .location("West Europe")
 *             .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 exampleResourceGroupPolicyAssignment = new ResourceGroupPolicyAssignment("exampleResourceGroupPolicyAssignment", ResourceGroupPolicyAssignmentArgs.builder()
 *             .name("example")
 *             .resourceGroupId(example.id())
 *             .policyDefinitionId(exampleDefinition.id())
 *             .parameters("""
 *     {
 *       "tagName": {
 *         "value": "Business Unit"
 *       },
 *       "tagValue": {
 *         "value": "BU"
 *       }
 *     }
 *             """)
 *             .build());
 * 
 *     }
 * }
 * }
 * 
* <!--End PulumiCodeChooser --> * * ## Import * * Resource Group Policy Assignments can be imported using the `resource id`, e.g. * * ```sh * $ pulumi import azure:core/resourceGroupPolicyAssignment:ResourceGroupPolicyAssignment example /subscriptions/00000000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Authorization/policyAssignments/assignment1 * ``` * */ @ResourceType(type="azure:core/resourceGroupPolicyAssignment:ResourceGroupPolicyAssignment") public class ResourceGroupPolicyAssignment extends com.pulumi.resources.CustomResource { /** * A description which should be used for this Policy Assignment. * */ @Export(name="description", refs={String.class}, tree="[0]") private Output description; /** * @return A description which should be used for this Policy Assignment. * */ public Output> description() { return Codegen.optional(this.description); } /** * The Display Name for this Policy Assignment. * */ @Export(name="displayName", refs={String.class}, tree="[0]") private Output displayName; /** * @return The Display Name for this Policy Assignment. * */ public Output> displayName() { return Codegen.optional(this.displayName); } /** * Specifies if this Policy should be enforced or not? Defaults to `true`. * */ @Export(name="enforce", refs={Boolean.class}, tree="[0]") private Output enforce; /** * @return Specifies if this Policy should be enforced or not? Defaults to `true`. * */ public Output> enforce() { return Codegen.optional(this.enforce); } /** * An `identity` block as defined below. * * > **Note:** The `location` field must also be specified when `identity` is specified. * */ @Export(name="identity", refs={ResourceGroupPolicyAssignmentIdentity.class}, tree="[0]") private Output identity; /** * @return An `identity` block as defined below. * * > **Note:** The `location` field must also be specified when `identity` is specified. * */ public Output> identity() { return Codegen.optional(this.identity); } /** * The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created. * */ @Export(name="location", refs={String.class}, tree="[0]") private Output location; /** * @return The Azure Region where the Policy Assignment should exist. Changing this forces a new Policy Assignment to be created. * */ public Output location() { return this.location; } /** * A JSON mapping of any Metadata for this Policy. * */ @Export(name="metadata", refs={String.class}, tree="[0]") private Output metadata; /** * @return A JSON mapping of any Metadata for this Policy. * */ public Output metadata() { return this.metadata; } /** * The name which should be used for this Policy Assignment. Changing this forces a new Policy Assignment to be created. Cannot exceed 64 characters in length. * */ @Export(name="name", refs={String.class}, tree="[0]") private Output name; /** * @return The name which should be used for this Policy Assignment. Changing this forces a new Policy Assignment to be created. Cannot exceed 64 characters in length. * */ public Output name() { return this.name; } /** * One or more `non_compliance_message` blocks as defined below. * */ @Export(name="nonComplianceMessages", refs={List.class,ResourceGroupPolicyAssignmentNonComplianceMessage.class}, tree="[0,1]") private Output> nonComplianceMessages; /** * @return One or more `non_compliance_message` blocks as defined below. * */ public Output>> nonComplianceMessages() { return Codegen.optional(this.nonComplianceMessages); } /** * Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy. * */ @Export(name="notScopes", refs={List.class,String.class}, tree="[0,1]") private Output> notScopes; /** * @return Specifies a list of Resource Scopes (for example a Subscription, or a Resource Group) within this Management Group which are excluded from this Policy. * */ public Output>> notScopes() { return Codegen.optional(this.notScopes); } /** * One or more `overrides` blocks as defined below. More detail about `overrides` and `resource_selectors` see [policy assignment structure](https://learn.microsoft.com/en-us/azure/governance/policy/concepts/assignment-structure#resource-selectors-preview) * */ @Export(name="overrides", refs={List.class,ResourceGroupPolicyAssignmentOverride.class}, tree="[0,1]") private Output> overrides; /** * @return One or more `overrides` blocks as defined below. More detail about `overrides` and `resource_selectors` see [policy assignment structure](https://learn.microsoft.com/en-us/azure/governance/policy/concepts/assignment-structure#resource-selectors-preview) * */ public Output>> overrides() { return Codegen.optional(this.overrides); } /** * A JSON mapping of any Parameters for this Policy. * */ @Export(name="parameters", refs={String.class}, tree="[0]") private Output parameters; /** * @return A JSON mapping of any Parameters for this Policy. * */ public Output> parameters() { return Codegen.optional(this.parameters); } /** * The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created. * */ @Export(name="policyDefinitionId", refs={String.class}, tree="[0]") private Output policyDefinitionId; /** * @return The ID of the Policy Definition or Policy Definition Set. Changing this forces a new Policy Assignment to be created. * */ public Output policyDefinitionId() { return this.policyDefinitionId; } /** * The ID of the Resource Group where this Policy Assignment should be created. Changing this forces a new Policy Assignment to be created. * */ @Export(name="resourceGroupId", refs={String.class}, tree="[0]") private Output resourceGroupId; /** * @return The ID of the Resource Group where this Policy Assignment should be created. Changing this forces a new Policy Assignment to be created. * */ public Output resourceGroupId() { return this.resourceGroupId; } /** * One or more `resource_selectors` blocks as defined below to filter polices by resource properties. * */ @Export(name="resourceSelectors", refs={List.class,ResourceGroupPolicyAssignmentResourceSelector.class}, tree="[0,1]") private Output> resourceSelectors; /** * @return One or more `resource_selectors` blocks as defined below to filter polices by resource properties. * */ public Output>> resourceSelectors() { return Codegen.optional(this.resourceSelectors); } /** * * @param name The _unique_ name of the resulting resource. */ public ResourceGroupPolicyAssignment(java.lang.String name) { this(name, ResourceGroupPolicyAssignmentArgs.Empty); } /** * * @param name The _unique_ name of the resulting resource. * @param args The arguments to use to populate this resource's properties. */ public ResourceGroupPolicyAssignment(java.lang.String name, ResourceGroupPolicyAssignmentArgs args) { this(name, args, null); } /** * * @param name The _unique_ name of the resulting resource. * @param args The arguments to use to populate this resource's properties. * @param options A bag of options that control this resource's behavior. */ public ResourceGroupPolicyAssignment(java.lang.String name, ResourceGroupPolicyAssignmentArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("azure:core/resourceGroupPolicyAssignment:ResourceGroupPolicyAssignment", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false); } private ResourceGroupPolicyAssignment(java.lang.String name, Output id, @Nullable ResourceGroupPolicyAssignmentState state, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("azure:core/resourceGroupPolicyAssignment:ResourceGroupPolicyAssignment", name, state, makeResourceOptions(options, id), false); } private static ResourceGroupPolicyAssignmentArgs makeArgs(ResourceGroupPolicyAssignmentArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { if (options != null && options.getUrn().isPresent()) { return null; } return args == null ? ResourceGroupPolicyAssignmentArgs.Empty : args; } private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) { var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder() .version(Utilities.getVersion()) .build(); return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id); } /** * Get an existing Host 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 * @param options Optional settings to control the behavior of the CustomResource. */ public static ResourceGroupPolicyAssignment get(java.lang.String name, Output id, @Nullable ResourceGroupPolicyAssignmentState state, @Nullable com.pulumi.resources.CustomResourceOptions options) { return new ResourceGroupPolicyAssignment(name, id, state, options); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy