Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pulumi.gcp.orgpolicy.kotlin.CustomConstraintArgs.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.orgpolicy.kotlin
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.gcp.orgpolicy.CustomConstraintArgs.builder
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import kotlin.String
import kotlin.Suppress
import kotlin.collections.List
import kotlin.jvm.JvmName
/**
* Custom constraints are created by administrators to provide more granular and customizable control over the specific fields that are restricted by your organization policies.
* To get more information about CustomConstraint, see:
* * [API documentation](https://cloud.google.com/resource-manager/docs/reference/orgpolicy/rest/v2/organizations.constraints)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/resource-manager/docs/organization-policy/creating-managing-custom-constraints)
* * [Supported Services](https://cloud.google.com/resource-manager/docs/organization-policy/custom-constraint-supported-services)
* ## Example Usage
* ### Org Policy Custom Constraint Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const constraint = new gcp.orgpolicy.CustomConstraint("constraint", {
* name: "custom.disableGkeAutoUpgrade",
* parent: "organizations/123456789",
* actionType: "ALLOW",
* condition: "resource.management.autoUpgrade == false",
* methodTypes: [
* "CREATE",
* "UPDATE",
* ],
* resourceTypes: ["container.googleapis.com/NodePool"],
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* constraint = gcp.orgpolicy.CustomConstraint("constraint",
* name="custom.disableGkeAutoUpgrade",
* parent="organizations/123456789",
* action_type="ALLOW",
* condition="resource.management.autoUpgrade == false",
* method_types=[
* "CREATE",
* "UPDATE",
* ],
* resource_types=["container.googleapis.com/NodePool"])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var constraint = new Gcp.OrgPolicy.CustomConstraint("constraint", new()
* {
* Name = "custom.disableGkeAutoUpgrade",
* Parent = "organizations/123456789",
* ActionType = "ALLOW",
* Condition = "resource.management.autoUpgrade == false",
* MethodTypes = new[]
* {
* "CREATE",
* "UPDATE",
* },
* ResourceTypes = new[]
* {
* "container.googleapis.com/NodePool",
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/orgpolicy"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := orgpolicy.NewCustomConstraint(ctx, "constraint", &orgpolicy.CustomConstraintArgs{
* Name: pulumi.String("custom.disableGkeAutoUpgrade"),
* Parent: pulumi.String("organizations/123456789"),
* ActionType: pulumi.String("ALLOW"),
* Condition: pulumi.String("resource.management.autoUpgrade == false"),
* MethodTypes: pulumi.StringArray{
* pulumi.String("CREATE"),
* pulumi.String("UPDATE"),
* },
* ResourceTypes: pulumi.StringArray{
* pulumi.String("container.googleapis.com/NodePool"),
* },
* })
* 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.gcp.orgpolicy.CustomConstraint;
* import com.pulumi.gcp.orgpolicy.CustomConstraintArgs;
* 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 constraint = new CustomConstraint("constraint", CustomConstraintArgs.builder()
* .name("custom.disableGkeAutoUpgrade")
* .parent("organizations/123456789")
* .actionType("ALLOW")
* .condition("resource.management.autoUpgrade == false")
* .methodTypes(
* "CREATE",
* "UPDATE")
* .resourceTypes("container.googleapis.com/NodePool")
* .build());
* }
* }
* ```
* ```yaml
* resources:
* constraint:
* type: gcp:orgpolicy:CustomConstraint
* properties:
* name: custom.disableGkeAutoUpgrade
* parent: organizations/123456789
* actionType: ALLOW
* condition: resource.management.autoUpgrade == false
* methodTypes:
* - CREATE
* - UPDATE
* resourceTypes:
* - container.googleapis.com/NodePool
* ```
*
* ### Org Policy Custom Constraint Full
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const constraint = new gcp.orgpolicy.CustomConstraint("constraint", {
* name: "custom.disableGkeAutoUpgrade",
* parent: "organizations/123456789",
* displayName: "Disable GKE auto upgrade",
* description: "Only allow GKE NodePool resource to be created or updated if AutoUpgrade is not enabled where this custom constraint is enforced.",
* actionType: "ALLOW",
* condition: "resource.management.autoUpgrade == false",
* methodTypes: [
* "CREATE",
* "UPDATE",
* ],
* resourceTypes: ["container.googleapis.com/NodePool"],
* });
* const bool = new gcp.orgpolicy.Policy("bool", {
* name: pulumi.interpolate`organizations/123456789/policies/${constraint.name}`,
* parent: "organizations/123456789",
* spec: {
* rules: [{
* enforce: "TRUE",
* }],
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* constraint = gcp.orgpolicy.CustomConstraint("constraint",
* name="custom.disableGkeAutoUpgrade",
* parent="organizations/123456789",
* display_name="Disable GKE auto upgrade",
* description="Only allow GKE NodePool resource to be created or updated if AutoUpgrade is not enabled where this custom constraint is enforced.",
* action_type="ALLOW",
* condition="resource.management.autoUpgrade == false",
* method_types=[
* "CREATE",
* "UPDATE",
* ],
* resource_types=["container.googleapis.com/NodePool"])
* bool = gcp.orgpolicy.Policy("bool",
* name=constraint.name.apply(lambda name: f"organizations/123456789/policies/{name}"),
* parent="organizations/123456789",
* spec={
* "rules": [{
* "enforce": "TRUE",
* }],
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var constraint = new Gcp.OrgPolicy.CustomConstraint("constraint", new()
* {
* Name = "custom.disableGkeAutoUpgrade",
* Parent = "organizations/123456789",
* DisplayName = "Disable GKE auto upgrade",
* Description = "Only allow GKE NodePool resource to be created or updated if AutoUpgrade is not enabled where this custom constraint is enforced.",
* ActionType = "ALLOW",
* Condition = "resource.management.autoUpgrade == false",
* MethodTypes = new[]
* {
* "CREATE",
* "UPDATE",
* },
* ResourceTypes = new[]
* {
* "container.googleapis.com/NodePool",
* },
* });
* var @bool = new Gcp.OrgPolicy.Policy("bool", new()
* {
* Name = constraint.Name.Apply(name => $"organizations/123456789/policies/{name}"),
* Parent = "organizations/123456789",
* Spec = new Gcp.OrgPolicy.Inputs.PolicySpecArgs
* {
* Rules = new[]
* {
* new Gcp.OrgPolicy.Inputs.PolicySpecRuleArgs
* {
* Enforce = "TRUE",
* },
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "fmt"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/orgpolicy"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* constraint, err := orgpolicy.NewCustomConstraint(ctx, "constraint", &orgpolicy.CustomConstraintArgs{
* Name: pulumi.String("custom.disableGkeAutoUpgrade"),
* Parent: pulumi.String("organizations/123456789"),
* DisplayName: pulumi.String("Disable GKE auto upgrade"),
* Description: pulumi.String("Only allow GKE NodePool resource to be created or updated if AutoUpgrade is not enabled where this custom constraint is enforced."),
* ActionType: pulumi.String("ALLOW"),
* Condition: pulumi.String("resource.management.autoUpgrade == false"),
* MethodTypes: pulumi.StringArray{
* pulumi.String("CREATE"),
* pulumi.String("UPDATE"),
* },
* ResourceTypes: pulumi.StringArray{
* pulumi.String("container.googleapis.com/NodePool"),
* },
* })
* if err != nil {
* return err
* }
* _, err = orgpolicy.NewPolicy(ctx, "bool", &orgpolicy.PolicyArgs{
* Name: constraint.Name.ApplyT(func(name string) (string, error) {
* return fmt.Sprintf("organizations/123456789/policies/%v", name), nil
* }).(pulumi.StringOutput),
* Parent: pulumi.String("organizations/123456789"),
* Spec: &orgpolicy.PolicySpecArgs{
* Rules: orgpolicy.PolicySpecRuleArray{
* &orgpolicy.PolicySpecRuleArgs{
* Enforce: pulumi.String("TRUE"),
* },
* },
* },
* })
* 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.gcp.orgpolicy.CustomConstraint;
* import com.pulumi.gcp.orgpolicy.CustomConstraintArgs;
* import com.pulumi.gcp.orgpolicy.Policy;
* import com.pulumi.gcp.orgpolicy.PolicyArgs;
* import com.pulumi.gcp.orgpolicy.inputs.PolicySpecArgs;
* 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 constraint = new CustomConstraint("constraint", CustomConstraintArgs.builder()
* .name("custom.disableGkeAutoUpgrade")
* .parent("organizations/123456789")
* .displayName("Disable GKE auto upgrade")
* .description("Only allow GKE NodePool resource to be created or updated if AutoUpgrade is not enabled where this custom constraint is enforced.")
* .actionType("ALLOW")
* .condition("resource.management.autoUpgrade == false")
* .methodTypes(
* "CREATE",
* "UPDATE")
* .resourceTypes("container.googleapis.com/NodePool")
* .build());
* var bool = new Policy("bool", PolicyArgs.builder()
* .name(constraint.name().applyValue(name -> String.format("organizations/123456789/policies/%s", name)))
* .parent("organizations/123456789")
* .spec(PolicySpecArgs.builder()
* .rules(PolicySpecRuleArgs.builder()
* .enforce("TRUE")
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* constraint:
* type: gcp:orgpolicy:CustomConstraint
* properties:
* name: custom.disableGkeAutoUpgrade
* parent: organizations/123456789
* displayName: Disable GKE auto upgrade
* description: Only allow GKE NodePool resource to be created or updated if AutoUpgrade is not enabled where this custom constraint is enforced.
* actionType: ALLOW
* condition: resource.management.autoUpgrade == false
* methodTypes:
* - CREATE
* - UPDATE
* resourceTypes:
* - container.googleapis.com/NodePool
* bool:
* type: gcp:orgpolicy:Policy
* properties:
* name: organizations/123456789/policies/${constraint.name}
* parent: organizations/123456789
* spec:
* rules:
* - enforce: TRUE
* ```
*
* ## Import
* CustomConstraint can be imported using any of these accepted formats:
* * `{{parent}}/customConstraints/{{name}}`
* When using the `pulumi import` command, CustomConstraint can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:orgpolicy/customConstraint:CustomConstraint default {{parent}}/customConstraints/{{name}}
* ```
* @property actionType The action to take if the condition is met.
* Possible values are: `ALLOW`, `DENY`.
* @property condition A CEL condition that refers to a supported service resource, for example `resource.management.autoUpgrade == false`. For details about CEL usage, see [Common Expression Language](https://cloud.google.com/resource-manager/docs/organization-policy/creating-managing-custom-constraints#common_expression_language).
* @property description A human-friendly description of the constraint to display as an error message when the policy is violated.
* @property displayName A human-friendly name for the constraint.
* @property methodTypes A list of RESTful methods for which to enforce the constraint. Can be `CREATE`, `UPDATE`, or both. Not all Google Cloud services support both methods. To see supported methods for each service, find the service in [Supported services](https://cloud.google.com/resource-manager/docs/organization-policy/custom-constraint-supported-services).
* @property name Immutable. The name of the custom constraint. This is unique within the organization.
* @property parent The parent of the resource, an organization. Format should be `organizations/{organization_id}`.
* - - -
* @property resourceTypes Immutable. The fully qualified name of the Google Cloud REST resource containing the object and field you want to restrict. For example, `container.googleapis.com/NodePool`.
*/
public data class CustomConstraintArgs(
public val actionType: Output? = null,
public val condition: Output? = null,
public val description: Output? = null,
public val displayName: Output? = null,
public val methodTypes: Output>? = null,
public val name: Output? = null,
public val parent: Output? = null,
public val resourceTypes: Output>? = null,
) : ConvertibleToJava {
override fun toJava(): com.pulumi.gcp.orgpolicy.CustomConstraintArgs =
com.pulumi.gcp.orgpolicy.CustomConstraintArgs.builder()
.actionType(actionType?.applyValue({ args0 -> args0 }))
.condition(condition?.applyValue({ args0 -> args0 }))
.description(description?.applyValue({ args0 -> args0 }))
.displayName(displayName?.applyValue({ args0 -> args0 }))
.methodTypes(methodTypes?.applyValue({ args0 -> args0.map({ args0 -> args0 }) }))
.name(name?.applyValue({ args0 -> args0 }))
.parent(parent?.applyValue({ args0 -> args0 }))
.resourceTypes(resourceTypes?.applyValue({ args0 -> args0.map({ args0 -> args0 }) })).build()
}
/**
* Builder for [CustomConstraintArgs].
*/
@PulumiTagMarker
public class CustomConstraintArgsBuilder internal constructor() {
private var actionType: Output? = null
private var condition: Output? = null
private var description: Output? = null
private var displayName: Output? = null
private var methodTypes: Output>? = null
private var name: Output? = null
private var parent: Output? = null
private var resourceTypes: Output>? = null
/**
* @param value The action to take if the condition is met.
* Possible values are: `ALLOW`, `DENY`.
*/
@JvmName("qgnjqpefhnalhisk")
public suspend fun actionType(`value`: Output) {
this.actionType = value
}
/**
* @param value A CEL condition that refers to a supported service resource, for example `resource.management.autoUpgrade == false`. For details about CEL usage, see [Common Expression Language](https://cloud.google.com/resource-manager/docs/organization-policy/creating-managing-custom-constraints#common_expression_language).
*/
@JvmName("nfbimdeixwleuchg")
public suspend fun condition(`value`: Output) {
this.condition = value
}
/**
* @param value A human-friendly description of the constraint to display as an error message when the policy is violated.
*/
@JvmName("cmyjdbqehyblrfgj")
public suspend fun description(`value`: Output) {
this.description = value
}
/**
* @param value A human-friendly name for the constraint.
*/
@JvmName("yocbngduurpwounl")
public suspend fun displayName(`value`: Output) {
this.displayName = value
}
/**
* @param value A list of RESTful methods for which to enforce the constraint. Can be `CREATE`, `UPDATE`, or both. Not all Google Cloud services support both methods. To see supported methods for each service, find the service in [Supported services](https://cloud.google.com/resource-manager/docs/organization-policy/custom-constraint-supported-services).
*/
@JvmName("lpojhckvgiijliva")
public suspend fun methodTypes(`value`: Output>) {
this.methodTypes = value
}
@JvmName("doalvplxoppmhsaj")
public suspend fun methodTypes(vararg values: Output) {
this.methodTypes = Output.all(values.asList())
}
/**
* @param values A list of RESTful methods for which to enforce the constraint. Can be `CREATE`, `UPDATE`, or both. Not all Google Cloud services support both methods. To see supported methods for each service, find the service in [Supported services](https://cloud.google.com/resource-manager/docs/organization-policy/custom-constraint-supported-services).
*/
@JvmName("jasglimrshxgkckb")
public suspend fun methodTypes(values: List>) {
this.methodTypes = Output.all(values)
}
/**
* @param value Immutable. The name of the custom constraint. This is unique within the organization.
*/
@JvmName("dpccpylmbcegsehp")
public suspend fun name(`value`: Output) {
this.name = value
}
/**
* @param value The parent of the resource, an organization. Format should be `organizations/{organization_id}`.
* - - -
*/
@JvmName("rxhklknhhyfvvhay")
public suspend fun parent(`value`: Output) {
this.parent = value
}
/**
* @param value Immutable. The fully qualified name of the Google Cloud REST resource containing the object and field you want to restrict. For example, `container.googleapis.com/NodePool`.
*/
@JvmName("sjdqpwkwlbsnwefm")
public suspend fun resourceTypes(`value`: Output>) {
this.resourceTypes = value
}
@JvmName("xsiwaflpegsmjomt")
public suspend fun resourceTypes(vararg values: Output) {
this.resourceTypes = Output.all(values.asList())
}
/**
* @param values Immutable. The fully qualified name of the Google Cloud REST resource containing the object and field you want to restrict. For example, `container.googleapis.com/NodePool`.
*/
@JvmName("rfjlbrbdswknwvok")
public suspend fun resourceTypes(values: List>) {
this.resourceTypes = Output.all(values)
}
/**
* @param value The action to take if the condition is met.
* Possible values are: `ALLOW`, `DENY`.
*/
@JvmName("juktcdicbsudafqy")
public suspend fun actionType(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.actionType = mapped
}
/**
* @param value A CEL condition that refers to a supported service resource, for example `resource.management.autoUpgrade == false`. For details about CEL usage, see [Common Expression Language](https://cloud.google.com/resource-manager/docs/organization-policy/creating-managing-custom-constraints#common_expression_language).
*/
@JvmName("kmqsucvmspnxamxb")
public suspend fun condition(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.condition = mapped
}
/**
* @param value A human-friendly description of the constraint to display as an error message when the policy is violated.
*/
@JvmName("axnwjjhflptmrnpd")
public suspend fun description(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.description = mapped
}
/**
* @param value A human-friendly name for the constraint.
*/
@JvmName("fyblgntlltyxeybc")
public suspend fun displayName(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.displayName = mapped
}
/**
* @param value A list of RESTful methods for which to enforce the constraint. Can be `CREATE`, `UPDATE`, or both. Not all Google Cloud services support both methods. To see supported methods for each service, find the service in [Supported services](https://cloud.google.com/resource-manager/docs/organization-policy/custom-constraint-supported-services).
*/
@JvmName("xuaaninrueugwdam")
public suspend fun methodTypes(`value`: List?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.methodTypes = mapped
}
/**
* @param values A list of RESTful methods for which to enforce the constraint. Can be `CREATE`, `UPDATE`, or both. Not all Google Cloud services support both methods. To see supported methods for each service, find the service in [Supported services](https://cloud.google.com/resource-manager/docs/organization-policy/custom-constraint-supported-services).
*/
@JvmName("petyucxvyxpuscnp")
public suspend fun methodTypes(vararg values: String) {
val toBeMapped = values.toList()
val mapped = toBeMapped.let({ args0 -> of(args0) })
this.methodTypes = mapped
}
/**
* @param value Immutable. The name of the custom constraint. This is unique within the organization.
*/
@JvmName("cvvjxknffrxvocfv")
public suspend fun name(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.name = mapped
}
/**
* @param value The parent of the resource, an organization. Format should be `organizations/{organization_id}`.
* - - -
*/
@JvmName("pxeysjbboeyedfcp")
public suspend fun parent(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.parent = mapped
}
/**
* @param value Immutable. The fully qualified name of the Google Cloud REST resource containing the object and field you want to restrict. For example, `container.googleapis.com/NodePool`.
*/
@JvmName("arlackcgulwabmgw")
public suspend fun resourceTypes(`value`: List?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.resourceTypes = mapped
}
/**
* @param values Immutable. The fully qualified name of the Google Cloud REST resource containing the object and field you want to restrict. For example, `container.googleapis.com/NodePool`.
*/
@JvmName("jbmyebdgrunkbcyb")
public suspend fun resourceTypes(vararg values: String) {
val toBeMapped = values.toList()
val mapped = toBeMapped.let({ args0 -> of(args0) })
this.resourceTypes = mapped
}
internal fun build(): CustomConstraintArgs = CustomConstraintArgs(
actionType = actionType,
condition = condition,
description = description,
displayName = displayName,
methodTypes = methodTypes,
name = name,
parent = parent,
resourceTypes = resourceTypes,
)
}