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

com.pulumi.azure.management.kotlin.GroupPolicyRemediation.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 6.15.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.management.kotlin

import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.Deprecated
import kotlin.Double
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List

/**
 * Builder for [GroupPolicyRemediation].
 */
@PulumiTagMarker
public class GroupPolicyRemediationResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: GroupPolicyRemediationArgs = GroupPolicyRemediationArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend GroupPolicyRemediationArgsBuilder.() -> Unit) {
        val builder = GroupPolicyRemediationArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): GroupPolicyRemediation {
        val builtJavaResource =
            com.pulumi.azure.management.GroupPolicyRemediation(
                this.name,
                this.args.toJava(),
                this.opts.toJava(),
            )
        return GroupPolicyRemediation(builtJavaResource)
    }
}

/**
 * Manages an Azure Management Group Policy Remediation.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const exampleGroup = new azure.management.Group("example", {displayName: "Example Management Group"});
 * const example = azure.policy.getPolicyDefintion({
 *     displayName: "Allowed locations",
 * });
 * const exampleGroupPolicyAssignment = new azure.management.GroupPolicyAssignment("example", {
 *     name: "exampleAssignment",
 *     managementGroupId: exampleGroup.id,
 *     policyDefinitionId: example.then(example => example.id),
 *     parameters: JSON.stringify({
 *         listOfAllowedLocations: {
 *             value: ["East US"],
 *         },
 *     }),
 * });
 * const exampleGroupPolicyRemediation = new azure.management.GroupPolicyRemediation("example", {
 *     name: "example",
 *     managementGroupId: exampleGroup.id,
 *     policyAssignmentId: exampleGroupPolicyAssignment.id,
 * });
 * ```
 * ```python
 * import pulumi
 * import json
 * import pulumi_azure as azure
 * example_group = azure.management.Group("example", display_name="Example Management Group")
 * example = azure.policy.get_policy_defintion(display_name="Allowed locations")
 * example_group_policy_assignment = azure.management.GroupPolicyAssignment("example",
 *     name="exampleAssignment",
 *     management_group_id=example_group.id,
 *     policy_definition_id=example.id,
 *     parameters=json.dumps({
 *         "listOfAllowedLocations": {
 *             "value": ["East US"],
 *         },
 *     }))
 * example_group_policy_remediation = azure.management.GroupPolicyRemediation("example",
 *     name="example",
 *     management_group_id=example_group.id,
 *     policy_assignment_id=example_group_policy_assignment.id)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using System.Text.Json;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var exampleGroup = new Azure.Management.Group("example", new()
 *     {
 *         DisplayName = "Example Management Group",
 *     });
 *     var example = Azure.Policy.GetPolicyDefintion.Invoke(new()
 *     {
 *         DisplayName = "Allowed locations",
 *     });
 *     var exampleGroupPolicyAssignment = new Azure.Management.GroupPolicyAssignment("example", new()
 *     {
 *         Name = "exampleAssignment",
 *         ManagementGroupId = exampleGroup.Id,
 *         PolicyDefinitionId = example.Apply(getPolicyDefintionResult => getPolicyDefintionResult.Id),
 *         Parameters = JsonSerializer.Serialize(new Dictionary
 *         {
 *             ["listOfAllowedLocations"] = new Dictionary
 *             {
 *                 ["value"] = new[]
 *                 {
 *                     "East US",
 *                 },
 *             },
 *         }),
 *     });
 *     var exampleGroupPolicyRemediation = new Azure.Management.GroupPolicyRemediation("example", new()
 *     {
 *         Name = "example",
 *         ManagementGroupId = exampleGroup.Id,
 *         PolicyAssignmentId = exampleGroupPolicyAssignment.Id,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"encoding/json"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/management"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/policy"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		exampleGroup, err := management.NewGroup(ctx, "example", &management.GroupArgs{
 * 			DisplayName: pulumi.String("Example Management Group"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		example, err := policy.GetPolicyDefintion(ctx, &policy.GetPolicyDefintionArgs{
 * 			DisplayName: pulumi.StringRef("Allowed locations"),
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		tmpJSON0, err := json.Marshal(map[string]interface{}{
 * 			"listOfAllowedLocations": map[string]interface{}{
 * 				"value": []string{
 * 					"East US",
 * 				},
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		json0 := string(tmpJSON0)
 * 		exampleGroupPolicyAssignment, err := management.NewGroupPolicyAssignment(ctx, "example", &management.GroupPolicyAssignmentArgs{
 * 			Name:               pulumi.String("exampleAssignment"),
 * 			ManagementGroupId:  exampleGroup.ID(),
 * 			PolicyDefinitionId: pulumi.String(example.Id),
 * 			Parameters:         pulumi.String(json0),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = management.NewGroupPolicyRemediation(ctx, "example", &management.GroupPolicyRemediationArgs{
 * 			Name:               pulumi.String("example"),
 * 			ManagementGroupId:  exampleGroup.ID(),
 * 			PolicyAssignmentId: exampleGroupPolicyAssignment.ID(),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.azure.management.Group;
 * import com.pulumi.azure.management.GroupArgs;
 * import com.pulumi.azure.policy.PolicyFunctions;
 * import com.pulumi.azure.policy.inputs.GetPolicyDefintionArgs;
 * import com.pulumi.azure.management.GroupPolicyAssignment;
 * import com.pulumi.azure.management.GroupPolicyAssignmentArgs;
 * import com.pulumi.azure.management.GroupPolicyRemediation;
 * import com.pulumi.azure.management.GroupPolicyRemediationArgs;
 * import static com.pulumi.codegen.internal.Serialization.*;
 * 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 exampleGroup = new Group("exampleGroup", GroupArgs.builder()
 *             .displayName("Example Management Group")
 *             .build());
 *         final var example = PolicyFunctions.getPolicyDefintion(GetPolicyDefintionArgs.builder()
 *             .displayName("Allowed locations")
 *             .build());
 *         var exampleGroupPolicyAssignment = new GroupPolicyAssignment("exampleGroupPolicyAssignment", GroupPolicyAssignmentArgs.builder()
 *             .name("exampleAssignment")
 *             .managementGroupId(exampleGroup.id())
 *             .policyDefinitionId(example.applyValue(getPolicyDefintionResult -> getPolicyDefintionResult.id()))
 *             .parameters(serializeJson(
 *                 jsonObject(
 *                     jsonProperty("listOfAllowedLocations", jsonObject(
 *                         jsonProperty("value", jsonArray("East US"))
 *                     ))
 *                 )))
 *             .build());
 *         var exampleGroupPolicyRemediation = new GroupPolicyRemediation("exampleGroupPolicyRemediation", GroupPolicyRemediationArgs.builder()
 *             .name("example")
 *             .managementGroupId(exampleGroup.id())
 *             .policyAssignmentId(exampleGroupPolicyAssignment.id())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   exampleGroup:
 *     type: azure:management:Group
 *     name: example
 *     properties:
 *       displayName: Example Management Group
 *   exampleGroupPolicyAssignment:
 *     type: azure:management:GroupPolicyAssignment
 *     name: example
 *     properties:
 *       name: exampleAssignment
 *       managementGroupId: ${exampleGroup.id}
 *       policyDefinitionId: ${example.id}
 *       parameters:
 *         fn::toJSON:
 *           listOfAllowedLocations:
 *             value:
 *               - East US
 *   exampleGroupPolicyRemediation:
 *     type: azure:management:GroupPolicyRemediation
 *     name: example
 *     properties:
 *       name: example
 *       managementGroupId: ${exampleGroup.id}
 *       policyAssignmentId: ${exampleGroupPolicyAssignment.id}
 * variables:
 *   example:
 *     fn::invoke:
 *       Function: azure:policy:getPolicyDefintion
 *       Arguments:
 *         displayName: Allowed locations
 * ```
 * 
 * ## Import
 * Policy Remediations can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:management/groupPolicyRemediation:GroupPolicyRemediation example /providers/Microsoft.Management/managementGroups/my-mgmt-group-id/providers/Microsoft.PolicyInsights/remediations/remediation1
 * ```
 */
public class GroupPolicyRemediation internal constructor(
    override val javaResource: com.pulumi.azure.management.GroupPolicyRemediation,
) : KotlinCustomResource(javaResource, GroupPolicyRemediationMapper) {
    /**
     * A number between 0.0 to 1.0 representing the percentage failure threshold. The remediation will fail if the percentage of failed remediation operations (i.e. failed deployments) exceeds this threshold.
     */
    public val failurePercentage: Output?
        get() = javaResource.failurePercentage().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * A list of the resource locations that will be remediated.
     */
    public val locationFilters: Output>?
        get() = javaResource.locationFilters().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0 })
            }).orElse(null)
        })

    /**
     * The Management Group ID at which the Policy Remediation should be applied. Changing this forces a new resource to be created.
     */
    public val managementGroupId: Output
        get() = javaResource.managementGroupId().applyValue({ args0 -> args0 })

    /**
     * The name of the Policy Remediation. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * Determines how many resources to remediate at any given time. Can be used to increase or reduce the pace of the remediation. If not provided, the default parallel deployments value is used.
     */
    public val parallelDeployments: Output?
        get() = javaResource.parallelDeployments().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The ID of the Policy Assignment that should be remediated.
     */
    public val policyAssignmentId: Output
        get() = javaResource.policyAssignmentId().applyValue({ args0 -> args0 })

    /**
     * The unique ID for the policy definition within the policy set definition that should be remediated. Required when the policy assignment being remediated assigns a policy set definition.
     * > **Note:** This property has been deprecated and will be removed in version 4.0 of the provider in favour of `policy_definition_reference_id`.
     */
    @Deprecated(
        message = """
  `policy_definition_id` will be removed in version 4.0 of the AzureRM Provider in favour of
      `policy_definition_reference_id`.
  """,
    )
    public val policyDefinitionId: Output?
        get() = javaResource.policyDefinitionId().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The unique ID for the policy definition reference within the policy set definition that should be remediated. Required when the policy assignment being remediated assigns a policy set definition.
     */
    public val policyDefinitionReferenceId: Output?
        get() = javaResource.policyDefinitionReferenceId().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Determines the max number of resources that can be remediated by the remediation job. If not provided, the default resource count is used.
     */
    public val resourceCount: Output?
        get() = javaResource.resourceCount().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The way that resources to remediate are discovered. Possible values are `ExistingNonCompliant`, `ReEvaluateCompliance`. Defaults to `ExistingNonCompliant`.
     * > **Note:** This property has been deprecated and will be removed in version 4.0 of the provider as evaluating compliance before remediation is only supported at subscription scope and below.
     */
    @Deprecated(
        message = """
  `resource_discovery_mode` will be removed in version 4.0 of the AzureRM Provider as evaluating
      compliance before remediation is only supported at subscription scope and below.
  """,
    )
    public val resourceDiscoveryMode: Output?
        get() = javaResource.resourceDiscoveryMode().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })
}

public object GroupPolicyRemediationMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.management.GroupPolicyRemediation::class == javaResource::class

    override fun map(javaResource: Resource): GroupPolicyRemediation =
        GroupPolicyRemediation(javaResource as com.pulumi.azure.management.GroupPolicyRemediation)
}

/**
 * @see [GroupPolicyRemediation].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [GroupPolicyRemediation].
 */
public suspend fun groupPolicyRemediation(
    name: String,
    block: suspend GroupPolicyRemediationResourceBuilder.() -> Unit,
): GroupPolicyRemediation {
    val builder = GroupPolicyRemediationResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [GroupPolicyRemediation].
 * @param name The _unique_ name of the resulting resource.
 */
public fun groupPolicyRemediation(name: String): GroupPolicyRemediation {
    val builder = GroupPolicyRemediationResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy