All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.gcp.organizations.kotlin.IAMBinding.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.IAMBindingCondition
import com.pulumi.gcp.organizations.kotlin.outputs.IAMBindingCondition.Companion.toKotlin
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.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List

/**
 * Builder for [IAMBinding].
 */
@PulumiTagMarker
public class IAMBindingResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: IAMBindingArgs = IAMBindingArgs()

    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 IAMBindingArgsBuilder.() -> Unit) {
        val builder = IAMBindingArgsBuilder()
        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(): IAMBinding {
        val builtJavaResource = com.pulumi.gcp.organizations.IAMBinding(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return IAMBinding(builtJavaResource)
    }
}

/**
 * Allows creation and management of a single binding within IAM policy for
 * an existing Google Cloud Platform Organization.
 * > **Note:** This resource __must not__ be used in conjunction with
 *    `gcp.organizations.IAMMember` for the __same role__ or they will fight over
 *    what your policy should be.
 * > **Note:** On create, this resource will overwrite members of any existing roles.
 *     Use `pulumi import` and inspect the `output to ensure
 *     your existing members are preserved.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const binding = new gcp.organizations.IAMBinding("binding", {
 *     orgId: "123456789",
 *     role: "roles/browser",
 *     members: ["user:alice@gmail.com"],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * binding = gcp.organizations.IAMBinding("binding",
 *     org_id="123456789",
 *     role="roles/browser",
 *     members=["user:alice@gmail.com"])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var binding = new Gcp.Organizations.IAMBinding("binding", new()
 *     {
 *         OrgId = "123456789",
 *         Role = "roles/browser",
 *         Members = new[]
 *         {
 *             "user:[email protected]",
 *         },
 *     });
 * });
 * ```
 * ```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.NewIAMBinding(ctx, "binding", &organizations.IAMBindingArgs{
 * 			OrgId: pulumi.String("123456789"),
 * 			Role:  pulumi.String("roles/browser"),
 * 			Members: pulumi.StringArray{
 * 				pulumi.String("user:[email protected]"),
 * 			},
 * 		})
 * 		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.IAMBinding;
 * import com.pulumi.gcp.organizations.IAMBindingArgs;
 * 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 binding = new IAMBinding("binding", IAMBindingArgs.builder()
 *             .orgId("123456789")
 *             .role("roles/browser")
 *             .members("user:[email protected]")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   binding:
 *     type: gcp:organizations:IAMBinding
 *     properties:
 *       orgId: '123456789'
 *       role: roles/browser
 *       members:
 *         - user:[email protected]
 * ```
 * 
 * ## Import
 * IAM binding imports use space-delimited identifiers; first the resource in question and then the role.  These bindings can be imported using the `org_id` and role, e.g.
 * ```sh
 * $ pulumi import gcp:organizations/iAMBinding:IAMBinding my_org "your-org-id roles/viewer"
 * ```
 * -> **Custom Roles**: If you're importing a IAM resource with a custom role, make sure to use the
 *  full name of the custom role, e.g. `[projects/my-project|organizations/my-org]/roles/my-custom-role`.
 */
public class IAMBinding internal constructor(
    override val javaResource: com.pulumi.gcp.organizations.IAMBinding,
) : KotlinCustomResource(javaResource, IAMBindingMapper) {
    public val condition: Output?
        get() = javaResource.condition().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    toKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * (Computed) The etag of the organization's IAM policy.
     */
    public val etag: Output
        get() = javaResource.etag().applyValue({ args0 -> args0 })

    /**
     * A list of users that the role should apply to. For more details on format and restrictions see https://cloud.google.com/billing/reference/rest/v1/Policy#Binding
     */
    public val members: Output>
        get() = javaResource.members().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * The numeric ID of the organization in which you want to create a custom role.
     */
    public val orgId: Output
        get() = javaResource.orgId().applyValue({ args0 -> args0 })

    /**
     * The role that should be applied. Only one
     * `gcp.organizations.IAMBinding` can be used per role. Note that custom roles must be of the format
     * `[projects|organizations]/{parent-name}/roles/{role-name}`.
     */
    public val role: Output
        get() = javaResource.role().applyValue({ args0 -> args0 })
}

public object IAMBindingMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.organizations.IAMBinding::class == javaResource::class

    override fun map(javaResource: Resource): IAMBinding = IAMBinding(
        javaResource as
            com.pulumi.gcp.organizations.IAMBinding,
    )
}

/**
 * @see [IAMBinding].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [IAMBinding].
 */
public suspend fun iamBinding(name: String, block: suspend IAMBindingResourceBuilder.() -> Unit): IAMBinding {
    val builder = IAMBindingResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [IAMBinding].
 * @param name The _unique_ name of the resulting resource.
 */
public fun iamBinding(name: String): IAMBinding {
    val builder = IAMBindingResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy