com.pulumi.gcp.folder.kotlin.OrganizationPolicy.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.folder.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.folder.kotlin.outputs.OrganizationPolicyBooleanPolicy
import com.pulumi.gcp.folder.kotlin.outputs.OrganizationPolicyListPolicy
import com.pulumi.gcp.folder.kotlin.outputs.OrganizationPolicyRestorePolicy
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.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import com.pulumi.gcp.folder.kotlin.outputs.OrganizationPolicyBooleanPolicy.Companion.toKotlin as organizationPolicyBooleanPolicyToKotlin
import com.pulumi.gcp.folder.kotlin.outputs.OrganizationPolicyListPolicy.Companion.toKotlin as organizationPolicyListPolicyToKotlin
import com.pulumi.gcp.folder.kotlin.outputs.OrganizationPolicyRestorePolicy.Companion.toKotlin as organizationPolicyRestorePolicyToKotlin
/**
* Builder for [OrganizationPolicy].
*/
@PulumiTagMarker
public class OrganizationPolicyResourceBuilder internal constructor() {
public var name: String? = null
public var args: OrganizationPolicyArgs = OrganizationPolicyArgs()
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 OrganizationPolicyArgsBuilder.() -> Unit) {
val builder = OrganizationPolicyArgsBuilder()
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(): OrganizationPolicy {
val builtJavaResource = com.pulumi.gcp.folder.OrganizationPolicy(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return OrganizationPolicy(builtJavaResource)
}
}
/**
* Allows management of Organization Policies for a Google Cloud Folder.
* > **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/folders/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.folder.OrganizationPolicy("serial_port_policy", {
* folder: "folders/123456789",
* constraint: "compute.disableSerialPortAccess",
* booleanPolicy: {
* enforced: true,
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* serial_port_policy = gcp.folder.OrganizationPolicy("serial_port_policy",
* folder="folders/123456789",
* constraint="compute.disableSerialPortAccess",
* boolean_policy=gcp.folder.OrganizationPolicyBooleanPolicyArgs(
* enforced=True,
* ))
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var serialPortPolicy = new Gcp.Folder.OrganizationPolicy("serial_port_policy", new()
* {
* Folder = "folders/123456789",
* Constraint = "compute.disableSerialPortAccess",
* BooleanPolicy = new Gcp.Folder.Inputs.OrganizationPolicyBooleanPolicyArgs
* {
* Enforced = true,
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/folder"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := folder.NewOrganizationPolicy(ctx, "serial_port_policy", &folder.OrganizationPolicyArgs{
* Folder: pulumi.String("folders/123456789"),
* Constraint: pulumi.String("compute.disableSerialPortAccess"),
* BooleanPolicy: &folder.OrganizationPolicyBooleanPolicyArgs{
* 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.folder.OrganizationPolicy;
* import com.pulumi.gcp.folder.OrganizationPolicyArgs;
* import com.pulumi.gcp.folder.inputs.OrganizationPolicyBooleanPolicyArgs;
* 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 OrganizationPolicy("serialPortPolicy", OrganizationPolicyArgs.builder()
* .folder("folders/123456789")
* .constraint("compute.disableSerialPortAccess")
* .booleanPolicy(OrganizationPolicyBooleanPolicyArgs.builder()
* .enforced(true)
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* serialPortPolicy:
* type: gcp:folder:OrganizationPolicy
* name: serial_port_policy
* properties:
* folder: folders/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.folder.OrganizationPolicy("services_policy", {
* folder: "folders/123456789",
* constraint: "serviceuser.services",
* listPolicy: {
* allow: {
* all: true,
* },
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* services_policy = gcp.folder.OrganizationPolicy("services_policy",
* folder="folders/123456789",
* constraint="serviceuser.services",
* list_policy=gcp.folder.OrganizationPolicyListPolicyArgs(
* allow=gcp.folder.OrganizationPolicyListPolicyAllowArgs(
* all=True,
* ),
* ))
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var servicesPolicy = new Gcp.Folder.OrganizationPolicy("services_policy", new()
* {
* Folder = "folders/123456789",
* Constraint = "serviceuser.services",
* ListPolicy = new Gcp.Folder.Inputs.OrganizationPolicyListPolicyArgs
* {
* Allow = new Gcp.Folder.Inputs.OrganizationPolicyListPolicyAllowArgs
* {
* All = true,
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/folder"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := folder.NewOrganizationPolicy(ctx, "services_policy", &folder.OrganizationPolicyArgs{
* Folder: pulumi.String("folders/123456789"),
* Constraint: pulumi.String("serviceuser.services"),
* ListPolicy: &folder.OrganizationPolicyListPolicyArgs{
* Allow: &folder.OrganizationPolicyListPolicyAllowArgs{
* 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.folder.OrganizationPolicy;
* import com.pulumi.gcp.folder.OrganizationPolicyArgs;
* import com.pulumi.gcp.folder.inputs.OrganizationPolicyListPolicyArgs;
* import com.pulumi.gcp.folder.inputs.OrganizationPolicyListPolicyAllowArgs;
* 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 OrganizationPolicy("servicesPolicy", OrganizationPolicyArgs.builder()
* .folder("folders/123456789")
* .constraint("serviceuser.services")
* .listPolicy(OrganizationPolicyListPolicyArgs.builder()
* .allow(OrganizationPolicyListPolicyAllowArgs.builder()
* .all(true)
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* servicesPolicy:
* type: gcp:folder:OrganizationPolicy
* name: services_policy
* properties:
* folder: folders/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.folder.OrganizationPolicy("services_policy", {
* folder: "folders/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.folder.OrganizationPolicy("services_policy",
* folder="folders/123456789",
* constraint="serviceuser.services",
* list_policy=gcp.folder.OrganizationPolicyListPolicyArgs(
* suggested_value="compute.googleapis.com",
* deny=gcp.folder.OrganizationPolicyListPolicyDenyArgs(
* 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.Folder.OrganizationPolicy("services_policy", new()
* {
* Folder = "folders/123456789",
* Constraint = "serviceuser.services",
* ListPolicy = new Gcp.Folder.Inputs.OrganizationPolicyListPolicyArgs
* {
* SuggestedValue = "compute.googleapis.com",
* Deny = new Gcp.Folder.Inputs.OrganizationPolicyListPolicyDenyArgs
* {
* Values = new[]
* {
* "cloudresourcemanager.googleapis.com",
* },
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/folder"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := folder.NewOrganizationPolicy(ctx, "services_policy", &folder.OrganizationPolicyArgs{
* Folder: pulumi.String("folders/123456789"),
* Constraint: pulumi.String("serviceuser.services"),
* ListPolicy: &folder.OrganizationPolicyListPolicyArgs{
* SuggestedValue: pulumi.String("compute.googleapis.com"),
* Deny: &folder.OrganizationPolicyListPolicyDenyArgs{
* 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.folder.OrganizationPolicy;
* import com.pulumi.gcp.folder.OrganizationPolicyArgs;
* import com.pulumi.gcp.folder.inputs.OrganizationPolicyListPolicyArgs;
* import com.pulumi.gcp.folder.inputs.OrganizationPolicyListPolicyDenyArgs;
* 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 OrganizationPolicy("servicesPolicy", OrganizationPolicyArgs.builder()
* .folder("folders/123456789")
* .constraint("serviceuser.services")
* .listPolicy(OrganizationPolicyListPolicyArgs.builder()
* .suggestedValue("compute.googleapis.com")
* .deny(OrganizationPolicyListPolicyDenyArgs.builder()
* .values("cloudresourcemanager.googleapis.com")
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* servicesPolicy:
* type: gcp:folder:OrganizationPolicy
* name: services_policy
* properties:
* folder: folders/123456789
* constraint: serviceuser.services
* listPolicy:
* suggestedValue: compute.googleapis.com
* deny:
* values:
* - cloudresourcemanager.googleapis.com
* ```
*
* To restore the default folder organization policy, use the following instead:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const servicesPolicy = new gcp.folder.OrganizationPolicy("services_policy", {
* folder: "folders/123456789",
* constraint: "serviceuser.services",
* restorePolicy: {
* "default": true,
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* services_policy = gcp.folder.OrganizationPolicy("services_policy",
* folder="folders/123456789",
* constraint="serviceuser.services",
* restore_policy=gcp.folder.OrganizationPolicyRestorePolicyArgs(
* default=True,
* ))
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var servicesPolicy = new Gcp.Folder.OrganizationPolicy("services_policy", new()
* {
* Folder = "folders/123456789",
* Constraint = "serviceuser.services",
* RestorePolicy = new Gcp.Folder.Inputs.OrganizationPolicyRestorePolicyArgs
* {
* Default = true,
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/folder"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := folder.NewOrganizationPolicy(ctx, "services_policy", &folder.OrganizationPolicyArgs{
* Folder: pulumi.String("folders/123456789"),
* Constraint: pulumi.String("serviceuser.services"),
* RestorePolicy: &folder.OrganizationPolicyRestorePolicyArgs{
* 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.folder.OrganizationPolicy;
* import com.pulumi.gcp.folder.OrganizationPolicyArgs;
* import com.pulumi.gcp.folder.inputs.OrganizationPolicyRestorePolicyArgs;
* 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 OrganizationPolicy("servicesPolicy", OrganizationPolicyArgs.builder()
* .folder("folders/123456789")
* .constraint("serviceuser.services")
* .restorePolicy(OrganizationPolicyRestorePolicyArgs.builder()
* .default_(true)
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* servicesPolicy:
* type: gcp:folder:OrganizationPolicy
* name: services_policy
* properties:
* folder: folders/123456789
* constraint: serviceuser.services
* restorePolicy:
* default: true
* ```
*
* ## Import
* Folder organization policies can be imported using any of the follow formats:
* * `folders/{{folder_id}}/constraints/serviceuser.services`
* * `{{folder_id}}/serviceuser.services`
* When using the `pulumi import` command, folder organization policies can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:folder/organizationPolicy:OrganizationPolicy * `google_folder_organization_policy.default folders/* ``{{folder_id}}/constraints/serviceuser.services`
* ```
* ```sh
* $ pulumi import gcp:folder/organizationPolicy:OrganizationPolicy * `* `google_folder_organization_policy.default {{folder_id}}/``serviceuser.services
* ```
* */
*/
public class OrganizationPolicy internal constructor(
override val javaResource: com.pulumi.gcp.folder.OrganizationPolicy,
) : KotlinCustomResource(javaResource, OrganizationPolicyMapper) {
/**
* A boolean policy is a constraint that is either enforced or not. Structure is documented below.
*/
public val booleanPolicy: Output?
get() = javaResource.booleanPolicy().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> organizationPolicyBooleanPolicyToKotlin(args0) })
}).orElse(null)
})
/**
* 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).
* - - -
*/
public val constraint: Output
get() = javaResource.constraint().applyValue({ args0 -> args0 })
/**
* (Computed) The etag of the organization policy. `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other.
*/
public val etag: Output
get() = javaResource.etag().applyValue({ args0 -> args0 })
/**
* The resource name of the folder to set the policy for. Its format is folders/{folder_id}.
*/
public val folder: Output
get() = javaResource.folder().applyValue({ args0 -> args0 })
/**
* 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.
*/
public val listPolicy: Output?
get() = javaResource.listPolicy().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
organizationPolicyListPolicyToKotlin(args0)
})
}).orElse(null)
})
/**
* 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'.
* - - -
*/
public val restorePolicy: Output?
get() = javaResource.restorePolicy().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> organizationPolicyRestorePolicyToKotlin(args0) })
}).orElse(null)
})
/**
* (Computed) The timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds, representing when the variable was last updated. Example: "2016-10-09T12:33:37.578138407Z".
*/
public val updateTime: Output
get() = javaResource.updateTime().applyValue({ args0 -> args0 })
/**
* Version of the Policy. Default version is 0.
*/
public val version: Output
get() = javaResource.version().applyValue({ args0 -> args0 })
}
public object OrganizationPolicyMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.folder.OrganizationPolicy::class == javaResource::class
override fun map(javaResource: Resource): OrganizationPolicy = OrganizationPolicy(
javaResource as
com.pulumi.gcp.folder.OrganizationPolicy,
)
}
/**
* @see [OrganizationPolicy].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [OrganizationPolicy].
*/
public suspend fun organizationPolicy(
name: String,
block: suspend OrganizationPolicyResourceBuilder.() -> Unit,
): OrganizationPolicy {
val builder = OrganizationPolicyResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [OrganizationPolicy].
* @param name The _unique_ name of the resulting resource.
*/
public fun organizationPolicy(name: String): OrganizationPolicy {
val builder = OrganizationPolicyResourceBuilder()
builder.name(name)
return builder.build()
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy