com.pulumi.gcp.organizations.kotlin.PolicyArgs.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-gcp-kotlin Show documentation
Show all versions of pulumi-gcp-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.organizations.kotlin
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.gcp.organizations.PolicyArgs.builder
import com.pulumi.gcp.organizations.kotlin.inputs.PolicyBooleanPolicyArgs
import com.pulumi.gcp.organizations.kotlin.inputs.PolicyBooleanPolicyArgsBuilder
import com.pulumi.gcp.organizations.kotlin.inputs.PolicyListPolicyArgs
import com.pulumi.gcp.organizations.kotlin.inputs.PolicyListPolicyArgsBuilder
import com.pulumi.gcp.organizations.kotlin.inputs.PolicyRestorePolicyArgs
import com.pulumi.gcp.organizations.kotlin.inputs.PolicyRestorePolicyArgsBuilder
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.jvm.JvmName
/**
* Allows management of Organization Policies for a Google Cloud Organization.
* > **Warning:** This resource has been superseded by `gcp.orgpolicy.Policy`. `gcp.orgpolicy.Policy` uses Organization Policy API V2 instead of Cloud Resource Manager API V1 and it supports additional features such as tags and conditions.
* To get more information about Organization Policies, see:
* * [API documentation](https://cloud.google.com/resource-manager/reference/rest/v1/organizations/setOrgPolicy)
* * How-to Guides
* * [Introduction to the Organization Policy Service](https://cloud.google.com/resource-manager/docs/organization-policy/overview)
* ## Example Usage
* To set policy with a [boolean constraint](https://cloud.google.com/resource-manager/docs/organization-policy/quickstart-boolean-constraints):
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const serialPortPolicy = new gcp.organizations.Policy("serial_port_policy", {
* orgId: "123456789",
* constraint: "compute.disableSerialPortAccess",
* booleanPolicy: {
* enforced: true,
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* serial_port_policy = gcp.organizations.Policy("serial_port_policy",
* org_id="123456789",
* constraint="compute.disableSerialPortAccess",
* boolean_policy=gcp.organizations.PolicyBooleanPolicyArgs(
* enforced=True,
* ))
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var serialPortPolicy = new Gcp.Organizations.Policy("serial_port_policy", new()
* {
* OrgId = "123456789",
* Constraint = "compute.disableSerialPortAccess",
* BooleanPolicy = new Gcp.Organizations.Inputs.PolicyBooleanPolicyArgs
* {
* Enforced = true,
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := organizations.NewPolicy(ctx, "serial_port_policy", &organizations.PolicyArgs{
* OrgId: pulumi.String("123456789"),
* Constraint: pulumi.String("compute.disableSerialPortAccess"),
* BooleanPolicy: &organizations.PolicyBooleanPolicyArgs{
* Enforced: pulumi.Bool(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.organizations.Policy;
* import com.pulumi.gcp.organizations.PolicyArgs;
* import com.pulumi.gcp.organizations.inputs.PolicyBooleanPolicyArgs;
* 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 serialPortPolicy = new Policy("serialPortPolicy", PolicyArgs.builder()
* .orgId("123456789")
* .constraint("compute.disableSerialPortAccess")
* .booleanPolicy(PolicyBooleanPolicyArgs.builder()
* .enforced(true)
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* serialPortPolicy:
* type: gcp:organizations:Policy
* name: serial_port_policy
* properties:
* orgId: '123456789'
* constraint: compute.disableSerialPortAccess
* booleanPolicy:
* enforced: true
* ```
*
* To set a policy with a [list constraint](https://cloud.google.com/resource-manager/docs/organization-policy/quickstart-list-constraints):
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const servicesPolicy = new gcp.organizations.Policy("services_policy", {
* orgId: "123456789",
* constraint: "serviceuser.services",
* listPolicy: {
* allow: {
* all: true,
* },
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* services_policy = gcp.organizations.Policy("services_policy",
* org_id="123456789",
* constraint="serviceuser.services",
* list_policy=gcp.organizations.PolicyListPolicyArgs(
* allow=gcp.organizations.PolicyListPolicyAllowArgs(
* all=True,
* ),
* ))
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var servicesPolicy = new Gcp.Organizations.Policy("services_policy", new()
* {
* OrgId = "123456789",
* Constraint = "serviceuser.services",
* ListPolicy = new Gcp.Organizations.Inputs.PolicyListPolicyArgs
* {
* Allow = new Gcp.Organizations.Inputs.PolicyListPolicyAllowArgs
* {
* All = true,
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := organizations.NewPolicy(ctx, "services_policy", &organizations.PolicyArgs{
* OrgId: pulumi.String("123456789"),
* Constraint: pulumi.String("serviceuser.services"),
* ListPolicy: &organizations.PolicyListPolicyArgs{
* Allow: &organizations.PolicyListPolicyAllowArgs{
* All: pulumi.Bool(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.organizations.Policy;
* import com.pulumi.gcp.organizations.PolicyArgs;
* import com.pulumi.gcp.organizations.inputs.PolicyListPolicyArgs;
* import com.pulumi.gcp.organizations.inputs.PolicyListPolicyAllowArgs;
* 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 servicesPolicy = new Policy("servicesPolicy", PolicyArgs.builder()
* .orgId("123456789")
* .constraint("serviceuser.services")
* .listPolicy(PolicyListPolicyArgs.builder()
* .allow(PolicyListPolicyAllowArgs.builder()
* .all(true)
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* servicesPolicy:
* type: gcp:organizations:Policy
* name: services_policy
* properties:
* orgId: '123456789'
* constraint: serviceuser.services
* listPolicy:
* allow:
* all: true
* ```
*
* Or to deny some services, use the following instead:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const servicesPolicy = new gcp.organizations.Policy("services_policy", {
* orgId: "123456789",
* constraint: "serviceuser.services",
* listPolicy: {
* suggestedValue: "compute.googleapis.com",
* deny: {
* values: ["cloudresourcemanager.googleapis.com"],
* },
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* services_policy = gcp.organizations.Policy("services_policy",
* org_id="123456789",
* constraint="serviceuser.services",
* list_policy=gcp.organizations.PolicyListPolicyArgs(
* suggested_value="compute.googleapis.com",
* deny=gcp.organizations.PolicyListPolicyDenyArgs(
* values=["cloudresourcemanager.googleapis.com"],
* ),
* ))
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var servicesPolicy = new Gcp.Organizations.Policy("services_policy", new()
* {
* OrgId = "123456789",
* Constraint = "serviceuser.services",
* ListPolicy = new Gcp.Organizations.Inputs.PolicyListPolicyArgs
* {
* SuggestedValue = "compute.googleapis.com",
* Deny = new Gcp.Organizations.Inputs.PolicyListPolicyDenyArgs
* {
* Values = new[]
* {
* "cloudresourcemanager.googleapis.com",
* },
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := organizations.NewPolicy(ctx, "services_policy", &organizations.PolicyArgs{
* OrgId: pulumi.String("123456789"),
* Constraint: pulumi.String("serviceuser.services"),
* ListPolicy: &organizations.PolicyListPolicyArgs{
* SuggestedValue: pulumi.String("compute.googleapis.com"),
* Deny: &organizations.PolicyListPolicyDenyArgs{
* Values: pulumi.StringArray{
* pulumi.String("cloudresourcemanager.googleapis.com"),
* },
* },
* },
* })
* 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.organizations.Policy;
* import com.pulumi.gcp.organizations.PolicyArgs;
* import com.pulumi.gcp.organizations.inputs.PolicyListPolicyArgs;
* import com.pulumi.gcp.organizations.inputs.PolicyListPolicyDenyArgs;
* 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 servicesPolicy = new Policy("servicesPolicy", PolicyArgs.builder()
* .orgId("123456789")
* .constraint("serviceuser.services")
* .listPolicy(PolicyListPolicyArgs.builder()
* .suggestedValue("compute.googleapis.com")
* .deny(PolicyListPolicyDenyArgs.builder()
* .values("cloudresourcemanager.googleapis.com")
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* servicesPolicy:
* type: gcp:organizations:Policy
* name: services_policy
* properties:
* orgId: '123456789'
* constraint: serviceuser.services
* listPolicy:
* suggestedValue: compute.googleapis.com
* deny:
* values:
* - cloudresourcemanager.googleapis.com
* ```
*
* To restore the default organization policy, use the following instead:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const servicesPolicy = new gcp.organizations.Policy("services_policy", {
* orgId: "123456789",
* constraint: "serviceuser.services",
* restorePolicy: {
* "default": true,
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* services_policy = gcp.organizations.Policy("services_policy",
* org_id="123456789",
* constraint="serviceuser.services",
* restore_policy=gcp.organizations.PolicyRestorePolicyArgs(
* default=True,
* ))
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var servicesPolicy = new Gcp.Organizations.Policy("services_policy", new()
* {
* OrgId = "123456789",
* Constraint = "serviceuser.services",
* RestorePolicy = new Gcp.Organizations.Inputs.PolicyRestorePolicyArgs
* {
* Default = true,
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := organizations.NewPolicy(ctx, "services_policy", &organizations.PolicyArgs{
* OrgId: pulumi.String("123456789"),
* Constraint: pulumi.String("serviceuser.services"),
* RestorePolicy: &organizations.PolicyRestorePolicyArgs{
* Default: pulumi.Bool(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.organizations.Policy;
* import com.pulumi.gcp.organizations.PolicyArgs;
* import com.pulumi.gcp.organizations.inputs.PolicyRestorePolicyArgs;
* 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 servicesPolicy = new Policy("servicesPolicy", PolicyArgs.builder()
* .orgId("123456789")
* .constraint("serviceuser.services")
* .restorePolicy(PolicyRestorePolicyArgs.builder()
* .default_(true)
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* servicesPolicy:
* type: gcp:organizations:Policy
* name: services_policy
* properties:
* orgId: '123456789'
* constraint: serviceuser.services
* restorePolicy:
* default: true
* ```
*
* ## Import
* Organization Policies can be imported using the `org_id` and the `constraint`, e.g.
* * `{{org_id}}/constraints/{{constraint}}`
* When using the `pulumi import` command, Organization Policies can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:organizations/policy:Policy default {{org_id}}/constraints/{{constraint}}
* ```
* It is all right if the constraint contains a slash, as in the example above.
* @property booleanPolicy A boolean policy is a constraint that is either enforced or not. Structure is documented
* below.
* @property constraint The name of the Constraint the Policy is configuring, for example, `serviceuser.services`. Check out the [complete list of available constraints](https://cloud.google.com/resource-manager/docs/organization-policy/understanding-constraints#available_constraints).
* - - -
* @property listPolicy A policy that can define specific values that are allowed or denied for the given constraint. It can also be used to allow or deny all values. Structure is documented below.
* @property orgId The numeric ID of the organization to set the policy for.
* @property restorePolicy A restore policy is a constraint to restore the default policy. Structure is documented below.
* > **Note:** If none of [`boolean_policy`, `list_policy`, `restore_policy`] are defined the policy for a given constraint will
* effectively be unset. This is represented in the UI as the constraint being 'Inherited'.
* - - -
* @property version Version of the Policy. Default version is 0.
*/
public data class PolicyArgs(
public val booleanPolicy: Output? = null,
public val constraint: Output? = null,
public val listPolicy: Output? = null,
public val orgId: Output? = null,
public val restorePolicy: Output? = null,
public val version: Output? = null,
) : ConvertibleToJava {
override fun toJava(): com.pulumi.gcp.organizations.PolicyArgs =
com.pulumi.gcp.organizations.PolicyArgs.builder()
.booleanPolicy(booleanPolicy?.applyValue({ args0 -> args0.let({ args0 -> args0.toJava() }) }))
.constraint(constraint?.applyValue({ args0 -> args0 }))
.listPolicy(listPolicy?.applyValue({ args0 -> args0.let({ args0 -> args0.toJava() }) }))
.orgId(orgId?.applyValue({ args0 -> args0 }))
.restorePolicy(restorePolicy?.applyValue({ args0 -> args0.let({ args0 -> args0.toJava() }) }))
.version(version?.applyValue({ args0 -> args0 })).build()
}
/**
* Builder for [PolicyArgs].
*/
@PulumiTagMarker
public class PolicyArgsBuilder internal constructor() {
private var booleanPolicy: Output? = null
private var constraint: Output? = null
private var listPolicy: Output? = null
private var orgId: Output? = null
private var restorePolicy: Output? = null
private var version: Output? = null
/**
* @param value A boolean policy is a constraint that is either enforced or not. Structure is documented
* below.
*/
@JvmName("brejnkccnwbihjyk")
public suspend fun booleanPolicy(`value`: Output) {
this.booleanPolicy = value
}
/**
* @param value The name of the Constraint the Policy is configuring, for example, `serviceuser.services`. Check out the [complete list of available constraints](https://cloud.google.com/resource-manager/docs/organization-policy/understanding-constraints#available_constraints).
* - - -
*/
@JvmName("ubbbsrgvpntocano")
public suspend fun constraint(`value`: Output) {
this.constraint = value
}
/**
* @param value A policy that can define specific values that are allowed or denied for the given constraint. It can also be used to allow or deny all values. Structure is documented below.
*/
@JvmName("sacqasdafwcauenp")
public suspend fun listPolicy(`value`: Output) {
this.listPolicy = value
}
/**
* @param value The numeric ID of the organization to set the policy for.
*/
@JvmName("dnkjmoucphcsussp")
public suspend fun orgId(`value`: Output) {
this.orgId = value
}
/**
* @param value A restore policy is a constraint to restore the default policy. Structure is documented below.
* > **Note:** If none of [`boolean_policy`, `list_policy`, `restore_policy`] are defined the policy for a given constraint will
* effectively be unset. This is represented in the UI as the constraint being 'Inherited'.
* - - -
*/
@JvmName("tldgtvqargtuggaa")
public suspend fun restorePolicy(`value`: Output) {
this.restorePolicy = value
}
/**
* @param value Version of the Policy. Default version is 0.
*/
@JvmName("ydlttggylqfvasrr")
public suspend fun version(`value`: Output) {
this.version = value
}
/**
* @param value A boolean policy is a constraint that is either enforced or not. Structure is documented
* below.
*/
@JvmName("dhhfncfxfrjdptgo")
public suspend fun booleanPolicy(`value`: PolicyBooleanPolicyArgs?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.booleanPolicy = mapped
}
/**
* @param argument A boolean policy is a constraint that is either enforced or not. Structure is documented
* below.
*/
@JvmName("oiakldgafevhjdnq")
public suspend fun booleanPolicy(argument: suspend PolicyBooleanPolicyArgsBuilder.() -> Unit) {
val toBeMapped = PolicyBooleanPolicyArgsBuilder().applySuspend { argument() }.build()
val mapped = of(toBeMapped)
this.booleanPolicy = mapped
}
/**
* @param value The name of the Constraint the Policy is configuring, for example, `serviceuser.services`. Check out the [complete list of available constraints](https://cloud.google.com/resource-manager/docs/organization-policy/understanding-constraints#available_constraints).
* - - -
*/
@JvmName("pvwlgamdkllbcbbb")
public suspend fun constraint(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.constraint = mapped
}
/**
* @param value A policy that can define specific values that are allowed or denied for the given constraint. It can also be used to allow or deny all values. Structure is documented below.
*/
@JvmName("grjfyxynjicdjvfm")
public suspend fun listPolicy(`value`: PolicyListPolicyArgs?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.listPolicy = mapped
}
/**
* @param argument A policy that can define specific values that are allowed or denied for the given constraint. It can also be used to allow or deny all values. Structure is documented below.
*/
@JvmName("sajkgajxxbamwvno")
public suspend fun listPolicy(argument: suspend PolicyListPolicyArgsBuilder.() -> Unit) {
val toBeMapped = PolicyListPolicyArgsBuilder().applySuspend { argument() }.build()
val mapped = of(toBeMapped)
this.listPolicy = mapped
}
/**
* @param value The numeric ID of the organization to set the policy for.
*/
@JvmName("mnfxlrmkiacliuxe")
public suspend fun orgId(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.orgId = mapped
}
/**
* @param value A restore policy is a constraint to restore the default policy. Structure is documented below.
* > **Note:** If none of [`boolean_policy`, `list_policy`, `restore_policy`] are defined the policy for a given constraint will
* effectively be unset. This is represented in the UI as the constraint being 'Inherited'.
* - - -
*/
@JvmName("hwfifypeamofjomx")
public suspend fun restorePolicy(`value`: PolicyRestorePolicyArgs?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.restorePolicy = mapped
}
/**
* @param argument A restore policy is a constraint to restore the default policy. Structure is documented below.
* > **Note:** If none of [`boolean_policy`, `list_policy`, `restore_policy`] are defined the policy for a given constraint will
* effectively be unset. This is represented in the UI as the constraint being 'Inherited'.
* - - -
*/
@JvmName("klefenooeiknlwce")
public suspend fun restorePolicy(argument: suspend PolicyRestorePolicyArgsBuilder.() -> Unit) {
val toBeMapped = PolicyRestorePolicyArgsBuilder().applySuspend { argument() }.build()
val mapped = of(toBeMapped)
this.restorePolicy = mapped
}
/**
* @param value Version of the Policy. Default version is 0.
*/
@JvmName("dsmticlyixkhorxt")
public suspend fun version(`value`: Int?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.version = mapped
}
internal fun build(): PolicyArgs = PolicyArgs(
booleanPolicy = booleanPolicy,
constraint = constraint,
listPolicy = listPolicy,
orgId = orgId,
restorePolicy = restorePolicy,
version = version,
)
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy