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

com.pulumi.gcp.organizations.kotlin.IAMCustomRole.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.organizations.kotlin

import com.pulumi.core.Output
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 [IAMCustomRole].
 */
@PulumiTagMarker
public class IAMCustomRoleResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: IAMCustomRoleArgs = IAMCustomRoleArgs()

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

/**
 * Allows management of a customized Cloud IAM organization role. For more information see
 * [the official documentation](https://cloud.google.com/iam/docs/understanding-custom-roles)
 * and
 * [API](https://cloud.google.com/iam/reference/rest/v1/organizations.roles).
 * > **Warning:** Note that custom roles in GCP have the concept of a soft-delete. There are two issues that may arise
 *  from this and how roles are propagated. 1) creating a role may involve undeleting and then updating a role with the
 *  same name, possibly causing confusing behavior between undelete and update. 2) A deleted role is permanently deleted
 *  after 7 days, but it can take up to 30 more days (i.e. between 7 and 37 days after deletion) before the role name is
 *  made available again. This means a deleted role that has been deleted for more than 7 days cannot be changed at all
 *  by the provider, and new roles cannot share that name.
 * ## Example Usage
 * This snippet creates a customized IAM organization role.
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const my_custom_role = new gcp.organizations.IAMCustomRole("my-custom-role", {
 *     roleId: "myCustomRole",
 *     orgId: "123456789",
 *     title: "My Custom Role",
 *     description: "A description",
 *     permissions: [
 *         "iam.roles.list",
 *         "iam.roles.create",
 *         "iam.roles.delete",
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * my_custom_role = gcp.organizations.IAMCustomRole("my-custom-role",
 *     role_id="myCustomRole",
 *     org_id="123456789",
 *     title="My Custom Role",
 *     description="A description",
 *     permissions=[
 *         "iam.roles.list",
 *         "iam.roles.create",
 *         "iam.roles.delete",
 *     ])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var my_custom_role = new Gcp.Organizations.IAMCustomRole("my-custom-role", new()
 *     {
 *         RoleId = "myCustomRole",
 *         OrgId = "123456789",
 *         Title = "My Custom Role",
 *         Description = "A description",
 *         Permissions = new[]
 *         {
 *             "iam.roles.list",
 *             "iam.roles.create",
 *             "iam.roles.delete",
 *         },
 *     });
 * });
 * ```
 * ```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.NewIAMCustomRole(ctx, "my-custom-role", &organizations.IAMCustomRoleArgs{
 * 			RoleId:      pulumi.String("myCustomRole"),
 * 			OrgId:       pulumi.String("123456789"),
 * 			Title:       pulumi.String("My Custom Role"),
 * 			Description: pulumi.String("A description"),
 * 			Permissions: pulumi.StringArray{
 * 				pulumi.String("iam.roles.list"),
 * 				pulumi.String("iam.roles.create"),
 * 				pulumi.String("iam.roles.delete"),
 * 			},
 * 		})
 * 		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.IAMCustomRole;
 * import com.pulumi.gcp.organizations.IAMCustomRoleArgs;
 * 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 my_custom_role = new IAMCustomRole("my-custom-role", IAMCustomRoleArgs.builder()
 *             .roleId("myCustomRole")
 *             .orgId("123456789")
 *             .title("My Custom Role")
 *             .description("A description")
 *             .permissions(
 *                 "iam.roles.list",
 *                 "iam.roles.create",
 *                 "iam.roles.delete")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   my-custom-role:
 *     type: gcp:organizations:IAMCustomRole
 *     properties:
 *       roleId: myCustomRole
 *       orgId: '123456789'
 *       title: My Custom Role
 *       description: A description
 *       permissions:
 *         - iam.roles.list
 *         - iam.roles.create
 *         - iam.roles.delete
 * ```
 * 
 * ## Import
 * Customized IAM organization role can be imported using their URI, e.g.
 * ```sh
 * $ pulumi import gcp:organizations/iAMCustomRole:IAMCustomRole my-custom-role organizations/123456789/roles/myCustomRole
 * ```
 */
public class IAMCustomRole internal constructor(
    override val javaResource: com.pulumi.gcp.organizations.IAMCustomRole,
) : KotlinCustomResource(javaResource, IAMCustomRoleMapper) {
    /**
     * (Optional) The current deleted state of the role.
     */
    public val deleted: Output
        get() = javaResource.deleted().applyValue({ args0 -> args0 })

    /**
     * A human-readable description for the role.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The name of the role in the format `organizations/{{org_id}}/roles/{{role_id}}`. Like `id`, this field can be used as a reference in other resources such as IAM role bindings.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ 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 names of the permissions this role grants when bound in an IAM policy. At least one permission must be specified.
     */
    public val permissions: Output>
        get() = javaResource.permissions().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * The role id to use for this role.
     */
    public val roleId: Output
        get() = javaResource.roleId().applyValue({ args0 -> args0 })

    /**
     * The current launch stage of the role.
     * Defaults to `GA`.
     * List of possible stages is [here](https://cloud.google.com/iam/reference/rest/v1/organizations.roles#Role.RoleLaunchStage).
     */
    public val stage: Output?
        get() = javaResource.stage().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * A human-readable title for the role.
     */
    public val title: Output
        get() = javaResource.title().applyValue({ args0 -> args0 })
}

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy