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.projects.kotlin.OrganizationPolicy.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.projects.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.projects.kotlin.outputs.OrganizationPolicyBooleanPolicy
import com.pulumi.gcp.projects.kotlin.outputs.OrganizationPolicyListPolicy
import com.pulumi.gcp.projects.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.projects.kotlin.outputs.OrganizationPolicyBooleanPolicy.Companion.toKotlin as organizationPolicyBooleanPolicyToKotlin
import com.pulumi.gcp.projects.kotlin.outputs.OrganizationPolicyListPolicy.Companion.toKotlin as organizationPolicyListPolicyToKotlin
import com.pulumi.gcp.projects.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.projects.OrganizationPolicy(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return OrganizationPolicy(builtJavaResource)
}
}
/**
* Allows management of Organization Policies for a Google Cloud Project.
* > **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/projects/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.projects.OrganizationPolicy("serial_port_policy", {
* project: "your-project-id",
* constraint: "compute.disableSerialPortAccess",
* booleanPolicy: {
* enforced: true,
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* serial_port_policy = gcp.projects.OrganizationPolicy("serial_port_policy",
* project="your-project-id",
* constraint="compute.disableSerialPortAccess",
* boolean_policy={
* "enforced": True,
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var serialPortPolicy = new Gcp.Projects.OrganizationPolicy("serial_port_policy", new()
* {
* Project = "your-project-id",
* Constraint = "compute.disableSerialPortAccess",
* BooleanPolicy = new Gcp.Projects.Inputs.OrganizationPolicyBooleanPolicyArgs
* {
* Enforced = true,
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := projects.NewOrganizationPolicy(ctx, "serial_port_policy", &projects.OrganizationPolicyArgs{
* Project: pulumi.String("your-project-id"),
* Constraint: pulumi.String("compute.disableSerialPortAccess"),
* BooleanPolicy: &projects.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.projects.OrganizationPolicy;
* import com.pulumi.gcp.projects.OrganizationPolicyArgs;
* import com.pulumi.gcp.projects.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()
* .project("your-project-id")
* .constraint("compute.disableSerialPortAccess")
* .booleanPolicy(OrganizationPolicyBooleanPolicyArgs.builder()
* .enforced(true)
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* serialPortPolicy:
* type: gcp:projects:OrganizationPolicy
* name: serial_port_policy
* properties:
* project: your-project-id
* 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.projects.OrganizationPolicy("services_policy", {
* project: "your-project-id",
* constraint: "serviceuser.services",
* listPolicy: {
* allow: {
* all: true,
* },
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* services_policy = gcp.projects.OrganizationPolicy("services_policy",
* project="your-project-id",
* constraint="serviceuser.services",
* list_policy={
* "allow": {
* "all": True,
* },
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var servicesPolicy = new Gcp.Projects.OrganizationPolicy("services_policy", new()
* {
* Project = "your-project-id",
* Constraint = "serviceuser.services",
* ListPolicy = new Gcp.Projects.Inputs.OrganizationPolicyListPolicyArgs
* {
* Allow = new Gcp.Projects.Inputs.OrganizationPolicyListPolicyAllowArgs
* {
* All = true,
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := projects.NewOrganizationPolicy(ctx, "services_policy", &projects.OrganizationPolicyArgs{
* Project: pulumi.String("your-project-id"),
* Constraint: pulumi.String("serviceuser.services"),
* ListPolicy: &projects.OrganizationPolicyListPolicyArgs{
* Allow: &projects.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.projects.OrganizationPolicy;
* import com.pulumi.gcp.projects.OrganizationPolicyArgs;
* import com.pulumi.gcp.projects.inputs.OrganizationPolicyListPolicyArgs;
* import com.pulumi.gcp.projects.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()
* .project("your-project-id")
* .constraint("serviceuser.services")
* .listPolicy(OrganizationPolicyListPolicyArgs.builder()
* .allow(OrganizationPolicyListPolicyAllowArgs.builder()
* .all(true)
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* servicesPolicy:
* type: gcp:projects:OrganizationPolicy
* name: services_policy
* properties:
* project: your-project-id
* 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.projects.OrganizationPolicy("services_policy", {
* project: "your-project-id",
* constraint: "serviceuser.services",
* listPolicy: {
* suggestedValue: "compute.googleapis.com",
* deny: {
* values: ["cloudresourcemanager.googleapis.com"],
* },
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* services_policy = gcp.projects.OrganizationPolicy("services_policy",
* project="your-project-id",
* constraint="serviceuser.services",
* list_policy={
* "suggested_value": "compute.googleapis.com",
* "deny": {
* "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.Projects.OrganizationPolicy("services_policy", new()
* {
* Project = "your-project-id",
* Constraint = "serviceuser.services",
* ListPolicy = new Gcp.Projects.Inputs.OrganizationPolicyListPolicyArgs
* {
* SuggestedValue = "compute.googleapis.com",
* Deny = new Gcp.Projects.Inputs.OrganizationPolicyListPolicyDenyArgs
* {
* Values = new[]
* {
* "cloudresourcemanager.googleapis.com",
* },
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := projects.NewOrganizationPolicy(ctx, "services_policy", &projects.OrganizationPolicyArgs{
* Project: pulumi.String("your-project-id"),
* Constraint: pulumi.String("serviceuser.services"),
* ListPolicy: &projects.OrganizationPolicyListPolicyArgs{
* SuggestedValue: pulumi.String("compute.googleapis.com"),
* Deny: &projects.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.projects.OrganizationPolicy;
* import com.pulumi.gcp.projects.OrganizationPolicyArgs;
* import com.pulumi.gcp.projects.inputs.OrganizationPolicyListPolicyArgs;
* import com.pulumi.gcp.projects.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()
* .project("your-project-id")
* .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:projects:OrganizationPolicy
* name: services_policy
* properties:
* project: your-project-id
* constraint: serviceuser.services
* listPolicy:
* suggestedValue: compute.googleapis.com
* deny:
* values:
* - cloudresourcemanager.googleapis.com
* ```
*
* To restore the default project organization policy, use the following instead:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const servicesPolicy = new gcp.projects.OrganizationPolicy("services_policy", {
* project: "your-project-id",
* constraint: "serviceuser.services",
* restorePolicy: {
* "default": true,
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* services_policy = gcp.projects.OrganizationPolicy("services_policy",
* project="your-project-id",
* constraint="serviceuser.services",
* restore_policy={
* "default": True,
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var servicesPolicy = new Gcp.Projects.OrganizationPolicy("services_policy", new()
* {
* Project = "your-project-id",
* Constraint = "serviceuser.services",
* RestorePolicy = new Gcp.Projects.Inputs.OrganizationPolicyRestorePolicyArgs
* {
* Default = true,
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := projects.NewOrganizationPolicy(ctx, "services_policy", &projects.OrganizationPolicyArgs{
* Project: pulumi.String("your-project-id"),
* Constraint: pulumi.String("serviceuser.services"),
* RestorePolicy: &projects.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.projects.OrganizationPolicy;
* import com.pulumi.gcp.projects.OrganizationPolicyArgs;
* import com.pulumi.gcp.projects.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()
* .project("your-project-id")
* .constraint("serviceuser.services")
* .restorePolicy(OrganizationPolicyRestorePolicyArgs.builder()
* .default_(true)
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* servicesPolicy:
* type: gcp:projects:OrganizationPolicy
* name: services_policy
* properties:
* project: your-project-id
* constraint: serviceuser.services
* restorePolicy:
* default: true
* ```
*
* ## Import
* Project organization policies can be imported using any of the follow formats:
* * `projects/{{project_id}}:constraints/{{constraint}}`
* * `{{project_id}}:constraints/{{constraint}}`
* * `{{project_id}}:{{constraint}}`
* When using the `pulumi import` command, project organization policies can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:projects/organizationPolicy:OrganizationPolicy default projects/{{project_id}}:constraints/{{constraint}}
* ```
* ```sh
* $ pulumi import gcp:projects/organizationPolicy:OrganizationPolicy default {{project_id}}:constraints/{{constraint}}
* ```
* ```sh
* $ pulumi import gcp:projects/organizationPolicy:OrganizationPolicy default {{project_id}}:{{constraint}}
* ```
*/
public class OrganizationPolicy internal constructor(
override val javaResource: com.pulumi.gcp.projects.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 })
/**
* 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)
})
/**
* The project id of the project to set the policy for.
*/
public val project: Output
get() = javaResource.project().applyValue({ args0 -> args0 })
/**
* 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.projects.OrganizationPolicy::class == javaResource::class
override fun map(javaResource: Resource): OrganizationPolicy = OrganizationPolicy(
javaResource as
com.pulumi.gcp.projects.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()
}