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

com.pulumi.azurenative.authorization.PolicyDefinition Maven / Gradle / Ivy

There is a newer version: 2.82.0
Show newest version
// *** 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.azurenative.authorization;

import com.pulumi.azurenative.Utilities;
import com.pulumi.azurenative.authorization.PolicyDefinitionArgs;
import com.pulumi.azurenative.authorization.outputs.ParameterDefinitionsValueResponse;
import com.pulumi.azurenative.authorization.outputs.SystemDataResponse;
import com.pulumi.core.Alias;
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.Object;
import java.lang.String;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * The policy definition.
 * Azure REST API version: 2021-06-01. Prior API version in Azure Native 1.x: 2020-09-01.
 * 
 * Other available API versions: 2016-04-01, 2018-05-01, 2019-06-01, 2023-04-01, 2024-05-01.
 * 
 * ## Example Usage
 * ### Create or update a policy definition
 * 
 * 
 * {@code
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.azurenative.authorization.PolicyDefinition;
 * import com.pulumi.azurenative.authorization.PolicyDefinitionArgs;
 * 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 policyDefinition = new PolicyDefinition("policyDefinition", PolicyDefinitionArgs.builder()
 *             .description("Force resource names to begin with given 'prefix' and/or end with given 'suffix'")
 *             .displayName("Enforce resource naming convention")
 *             .metadata(Map.of("category", "Naming"))
 *             .mode("All")
 *             .parameters(Map.ofEntries(
 *                 Map.entry("prefix", Map.ofEntries(
 *                     Map.entry("metadata", Map.ofEntries(
 *                         Map.entry("description", "Resource name prefix"),
 *                         Map.entry("displayName", "Prefix")
 *                     )),
 *                     Map.entry("type", "String")
 *                 )),
 *                 Map.entry("suffix", Map.ofEntries(
 *                     Map.entry("metadata", Map.ofEntries(
 *                         Map.entry("description", "Resource name suffix"),
 *                         Map.entry("displayName", "Suffix")
 *                     )),
 *                     Map.entry("type", "String")
 *                 ))
 *             ))
 *             .policyDefinitionName("ResourceNaming")
 *             .policyRule(Map.ofEntries(
 *                 Map.entry("if", Map.of("not", Map.ofEntries(
 *                     Map.entry("field", "name"),
 *                     Map.entry("like", "[concat(parameters('prefix'), '*', parameters('suffix'))]")
 *                 ))),
 *                 Map.entry("then", Map.of("effect", "deny"))
 *             ))
 *             .build());
 * 
 *     }
 * }
 * 
 * }
 * 
* ### Create or update a policy definition with advanced parameters * *
 * {@code
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.azurenative.authorization.PolicyDefinition;
 * import com.pulumi.azurenative.authorization.PolicyDefinitionArgs;
 * 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 policyDefinition = new PolicyDefinition("policyDefinition", PolicyDefinitionArgs.builder()
 *             .description("Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised")
 *             .displayName("Event Hubs should have diagnostic logging enabled")
 *             .metadata(Map.of("category", "Event Hub"))
 *             .mode("Indexed")
 *             .parameters(Map.of("requiredRetentionDays", Map.ofEntries(
 *                 Map.entry("allowedValues",                 
 *                     0,
 *                     30,
 *                     90,
 *                     180,
 *                     365),
 *                 Map.entry("defaultValue", 365),
 *                 Map.entry("metadata", Map.ofEntries(
 *                     Map.entry("description", "The required diagnostic logs retention in days"),
 *                     Map.entry("displayName", "Required retention (days)")
 *                 )),
 *                 Map.entry("type", "Integer")
 *             )))
 *             .policyDefinitionName("EventHubDiagnosticLogs")
 *             .policyRule(Map.ofEntries(
 *                 Map.entry("if", Map.ofEntries(
 *                     Map.entry("equals", "Microsoft.EventHub/namespaces"),
 *                     Map.entry("field", "type")
 *                 )),
 *                 Map.entry("then", Map.ofEntries(
 *                     Map.entry("details", Map.ofEntries(
 *                         Map.entry("existenceCondition", Map.of("allOf",                         
 *                             Map.ofEntries(
 *                                 Map.entry("equals", "true"),
 *                                 Map.entry("field", "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled")
 *                             ),
 *                             Map.ofEntries(
 *                                 Map.entry("equals", "[parameters('requiredRetentionDays')]"),
 *                                 Map.entry("field", "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days")
 *                             ))),
 *                         Map.entry("type", "Microsoft.Insights/diagnosticSettings")
 *                     )),
 *                     Map.entry("effect", "AuditIfNotExists")
 *                 ))
 *             ))
 *             .build());
 * 
 *     }
 * }
 * 
 * }
 * 
* * ## Import * * An existing resource can be imported using its type token, name, and identifier, e.g. * * ```sh * $ pulumi import azure-native:authorization:PolicyDefinition ResourceNaming /subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName} * ``` * */ @ResourceType(type="azure-native:authorization:PolicyDefinition") public class PolicyDefinition extends com.pulumi.resources.CustomResource { /** * The policy definition description. * */ @Export(name="description", refs={String.class}, tree="[0]") private Output description; /** * @return The policy definition description. * */ public Output> description() { return Codegen.optional(this.description); } /** * The display name of the policy definition. * */ @Export(name="displayName", refs={String.class}, tree="[0]") private Output displayName; /** * @return The display name of the policy definition. * */ public Output> displayName() { return Codegen.optional(this.displayName); } /** * The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. * */ @Export(name="metadata", refs={Object.class}, tree="[0]") private Output metadata; /** * @return The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. * */ public Output> metadata() { return Codegen.optional(this.metadata); } /** * The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. * */ @Export(name="mode", refs={String.class}, tree="[0]") private Output mode; /** * @return The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. * */ public Output> mode() { return Codegen.optional(this.mode); } /** * The name of the policy definition. * */ @Export(name="name", refs={String.class}, tree="[0]") private Output name; /** * @return The name of the policy definition. * */ public Output name() { return this.name; } /** * The parameter definitions for parameters used in the policy rule. The keys are the parameter names. * */ @Export(name="parameters", refs={Map.class,String.class,ParameterDefinitionsValueResponse.class}, tree="[0,1,2]") private Output> parameters; /** * @return The parameter definitions for parameters used in the policy rule. The keys are the parameter names. * */ public Output>> parameters() { return Codegen.optional(this.parameters); } /** * The policy rule. * */ @Export(name="policyRule", refs={Object.class}, tree="[0]") private Output policyRule; /** * @return The policy rule. * */ public Output> policyRule() { return Codegen.optional(this.policyRule); } /** * The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. * */ @Export(name="policyType", refs={String.class}, tree="[0]") private Output policyType; /** * @return The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. * */ public Output> policyType() { return Codegen.optional(this.policyType); } /** * The system metadata relating to this resource. * */ @Export(name="systemData", refs={SystemDataResponse.class}, tree="[0]") private Output systemData; /** * @return The system metadata relating to this resource. * */ public Output systemData() { return this.systemData; } /** * The type of the resource (Microsoft.Authorization/policyDefinitions). * */ @Export(name="type", refs={String.class}, tree="[0]") private Output type; /** * @return The type of the resource (Microsoft.Authorization/policyDefinitions). * */ public Output type() { return this.type; } /** * * @param name The _unique_ name of the resulting resource. */ public PolicyDefinition(java.lang.String name) { this(name, PolicyDefinitionArgs.Empty); } /** * * @param name The _unique_ name of the resulting resource. * @param args The arguments to use to populate this resource's properties. */ public PolicyDefinition(java.lang.String name, @Nullable PolicyDefinitionArgs 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 PolicyDefinition(java.lang.String name, @Nullable PolicyDefinitionArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("azure-native:authorization:PolicyDefinition", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false); } private PolicyDefinition(java.lang.String name, Output id, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("azure-native:authorization:PolicyDefinition", name, null, makeResourceOptions(options, id), false); } private static PolicyDefinitionArgs makeArgs(@Nullable PolicyDefinitionArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { if (options != null && options.getUrn().isPresent()) { return null; } return args == null ? PolicyDefinitionArgs.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()) .aliases(List.of( Output.of(Alias.builder().type("azure-native:authorization/v20151001preview:PolicyDefinition").build()), Output.of(Alias.builder().type("azure-native:authorization/v20160401:PolicyDefinition").build()), Output.of(Alias.builder().type("azure-native:authorization/v20161201:PolicyDefinition").build()), Output.of(Alias.builder().type("azure-native:authorization/v20180301:PolicyDefinition").build()), Output.of(Alias.builder().type("azure-native:authorization/v20180501:PolicyDefinition").build()), Output.of(Alias.builder().type("azure-native:authorization/v20190101:PolicyDefinition").build()), Output.of(Alias.builder().type("azure-native:authorization/v20190601:PolicyDefinition").build()), Output.of(Alias.builder().type("azure-native:authorization/v20190901:PolicyDefinition").build()), Output.of(Alias.builder().type("azure-native:authorization/v20200301:PolicyDefinition").build()), Output.of(Alias.builder().type("azure-native:authorization/v20200901:PolicyDefinition").build()), Output.of(Alias.builder().type("azure-native:authorization/v20210601:PolicyDefinition").build()), Output.of(Alias.builder().type("azure-native:authorization/v20230401:PolicyDefinition").build()), Output.of(Alias.builder().type("azure-native:authorization/v20240501:PolicyDefinition").build()) )) .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 options Optional settings to control the behavior of the CustomResource. */ public static PolicyDefinition get(java.lang.String name, Output id, @Nullable com.pulumi.resources.CustomResourceOptions options) { return new PolicyDefinition(name, id, options); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy