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.organizations.kotlin.Policy.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.organizations.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.organizations.kotlin.outputs.PolicyBooleanPolicy
import com.pulumi.gcp.organizations.kotlin.outputs.PolicyListPolicy
import com.pulumi.gcp.organizations.kotlin.outputs.PolicyRestorePolicy
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.organizations.kotlin.outputs.PolicyBooleanPolicy.Companion.toKotlin as policyBooleanPolicyToKotlin
import com.pulumi.gcp.organizations.kotlin.outputs.PolicyListPolicy.Companion.toKotlin as policyListPolicyToKotlin
import com.pulumi.gcp.organizations.kotlin.outputs.PolicyRestorePolicy.Companion.toKotlin as policyRestorePolicyToKotlin
/**
* Builder for [Policy].
*/
@PulumiTagMarker
public class PolicyResourceBuilder internal constructor() {
public var name: String? = null
public var args: PolicyArgs = PolicyArgs()
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 PolicyArgsBuilder.() -> Unit) {
val builder = PolicyArgsBuilder()
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(): Policy {
val builtJavaResource = com.pulumi.gcp.organizations.Policy(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return Policy(builtJavaResource)
}
}
/**
* 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={
* "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={
* "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.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={
* "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.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={
* "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.
*/
public class Policy internal constructor(
override val javaResource: com.pulumi.gcp.organizations.Policy,
) : KotlinCustomResource(javaResource, PolicyMapper) {
/**
* 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 -> policyBooleanPolicyToKotlin(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 ->
policyListPolicyToKotlin(args0)
})
}).orElse(null)
})
/**
* The numeric ID of the organization to set the policy for.
*/
public val orgId: Output
get() = javaResource.orgId().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 -> policyRestorePolicyToKotlin(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 PolicyMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.organizations.Policy::class == javaResource::class
override fun map(javaResource: Resource): Policy = Policy(
javaResource as
com.pulumi.gcp.organizations.Policy,
)
}
/**
* @see [Policy].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [Policy].
*/
public suspend fun policy(name: String, block: suspend PolicyResourceBuilder.() -> Unit): Policy {
val builder = PolicyResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [Policy].
* @param name The _unique_ name of the resulting resource.
*/
public fun policy(name: String): Policy {
val builder = PolicyResourceBuilder()
builder.name(name)
return builder.build()
}