![JAR search and dependency download from the Maven repository](/logo.png)
com.pulumi.azure.core.SubscriptionPolicyAssignment Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure Show documentation
Show all versions of azure Show documentation
A Pulumi package for creating and managing Microsoft Azure cloud resources, based on the Terraform azurerm provider. We recommend using the [Azure Native provider](https://github.com/pulumi/pulumi-azure-native) to provision Azure infrastructure. Azure Native provides complete coverage of Azure resources and same-day access to new resources and resource updates.
// *** 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.SubscriptionPolicyAssignmentArgs;
import com.pulumi.azure.core.inputs.SubscriptionPolicyAssignmentState;
import com.pulumi.azure.core.outputs.SubscriptionPolicyAssignmentIdentity;
import com.pulumi.azure.core.outputs.SubscriptionPolicyAssignmentNonComplianceMessage;
import com.pulumi.azure.core.outputs.SubscriptionPolicyAssignmentOverride;
import com.pulumi.azure.core.outputs.SubscriptionPolicyAssignmentResourceSelector;
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 Subscription 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.CoreFunctions;
* import com.pulumi.azure.core.inputs.GetSubscriptionArgs;
* import com.pulumi.azure.policy.Definition;
* import com.pulumi.azure.policy.DefinitionArgs;
* import com.pulumi.azure.core.SubscriptionPolicyAssignment;
* import com.pulumi.azure.core.SubscriptionPolicyAssignmentArgs;
* 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 current = CoreFunctions.getSubscription();
*
* var example = new Definition("example", DefinitionArgs.builder()
* .name("only-deploy-in-westeurope")
* .policyType("Custom")
* .mode("All")
* .displayName("Allowed resource types")
* .policyRule("""
* {
* "if": {
* "not": {
* "field": "location",
* "equals": "westeurope"
* }
* },
* "then": {
* "effect": "Deny"
* }
* }
* """)
* .build());
*
* var exampleSubscriptionPolicyAssignment = new SubscriptionPolicyAssignment("exampleSubscriptionPolicyAssignment", SubscriptionPolicyAssignmentArgs.builder()
* .name("example")
* .policyDefinitionId(example.id())
* .subscriptionId(current.applyValue(getSubscriptionResult -> getSubscriptionResult.id()))
* .build());
*
* }
* }
* }
*
* <!--End PulumiCodeChooser -->
*
* ## Import
*
* Subscription Policy Assignments can be imported using the `resource id`, e.g.
*
* ```sh
* $ pulumi import azure:core/subscriptionPolicyAssignment:SubscriptionPolicyAssignment example /subscriptions/00000000-0000-0000-000000000000/providers/Microsoft.Authorization/policyAssignments/assignment1
* ```
*
*/
@ResourceType(type="azure:core/subscriptionPolicyAssignment:SubscriptionPolicyAssignment")
public class SubscriptionPolicyAssignment 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* @Nullable */ String> 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* @Nullable */ String> 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* @Nullable */ Boolean> 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={SubscriptionPolicyAssignmentIdentity.class}, tree="[0]")
private Output* @Nullable */ SubscriptionPolicyAssignmentIdentity> 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,SubscriptionPolicyAssignmentNonComplianceMessage.class}, tree="[0,1]")
private Output* @Nullable */ List> 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* @Nullable */ List> 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,SubscriptionPolicyAssignmentOverride.class}, tree="[0,1]")
private Output* @Nullable */ List> 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* @Nullable */ String> 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;
}
/**
* One or more `resource_selectors` blocks as defined below to filter polices by resource properties.
*
*/
@Export(name="resourceSelectors", refs={List.class,SubscriptionPolicyAssignmentResourceSelector.class}, tree="[0,1]")
private Output* @Nullable */ List> 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);
}
/**
* The ID of the Subscription where this Policy Assignment should be created. Changing this forces a new Policy Assignment to be created.
*
*/
@Export(name="subscriptionId", refs={String.class}, tree="[0]")
private Output subscriptionId;
/**
* @return The ID of the Subscription where this Policy Assignment should be created. Changing this forces a new Policy Assignment to be created.
*
*/
public Output subscriptionId() {
return this.subscriptionId;
}
/**
*
* @param name The _unique_ name of the resulting resource.
*/
public SubscriptionPolicyAssignment(java.lang.String name) {
this(name, SubscriptionPolicyAssignmentArgs.Empty);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
*/
public SubscriptionPolicyAssignment(java.lang.String name, SubscriptionPolicyAssignmentArgs 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 SubscriptionPolicyAssignment(java.lang.String name, SubscriptionPolicyAssignmentArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("azure:core/subscriptionPolicyAssignment:SubscriptionPolicyAssignment", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false);
}
private SubscriptionPolicyAssignment(java.lang.String name, Output id, @Nullable SubscriptionPolicyAssignmentState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("azure:core/subscriptionPolicyAssignment:SubscriptionPolicyAssignment", name, state, makeResourceOptions(options, id), false);
}
private static SubscriptionPolicyAssignmentArgs makeArgs(SubscriptionPolicyAssignmentArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
if (options != null && options.getUrn().isPresent()) {
return null;
}
return args == null ? SubscriptionPolicyAssignmentArgs.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 SubscriptionPolicyAssignment get(java.lang.String name, Output id, @Nullable SubscriptionPolicyAssignmentState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
return new SubscriptionPolicyAssignment(name, id, state, options);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy