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

com.pulumi.gcp.iam.kotlin.ProjectsPolicyBinding.kt Maven / Gradle / Ivy

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

package com.pulumi.gcp.iam.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.iam.kotlin.outputs.ProjectsPolicyBindingCondition
import com.pulumi.gcp.iam.kotlin.outputs.ProjectsPolicyBindingTarget
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.Map
import com.pulumi.gcp.iam.kotlin.outputs.ProjectsPolicyBindingCondition.Companion.toKotlin as projectsPolicyBindingConditionToKotlin
import com.pulumi.gcp.iam.kotlin.outputs.ProjectsPolicyBindingTarget.Companion.toKotlin as projectsPolicyBindingTargetToKotlin

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

    public var args: ProjectsPolicyBindingArgs = ProjectsPolicyBindingArgs()

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

/**
 * A policy binding to a Project
 * To get more information about ProjectsPolicyBinding, see:
 * * [API documentation](https://cloud.google.com/iam/docs/reference/rest/v3/projects.locations.policyBindings)
 * * How-to Guides
 *     * [Apply a policy binding](https://cloud.google.com/iam/docs/principal-access-boundary-policies-create#create_binding)
 * ## Example Usage
 * ### Iam Projects Policy Binding
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const project = gcp.organizations.getProject({});
 * const pabPolicy = new gcp.iam.PrincipalAccessBoundaryPolicy("pab_policy", {
 *     organization: "123456789",
 *     location: "global",
 *     displayName: "test project binding",
 *     principalAccessBoundaryPolicyId: "my-pab-policy",
 * });
 * const my_project_binding = new gcp.iam.ProjectsPolicyBinding("my-project-binding", {
 *     project: project.then(project => project.projectId),
 *     location: "global",
 *     displayName: "test project binding",
 *     policyKind: "PRINCIPAL_ACCESS_BOUNDARY",
 *     policyBindingId: "test-project-binding",
 *     policy: pulumi.interpolate`organizations/123456789/locations/global/principalAccessBoundaryPolicies/${pabPolicy.principalAccessBoundaryPolicyId}`,
 *     target: {
 *         principalSet: project.then(project => `//cloudresourcemanager.googleapis.com/projects/${project.projectId}`),
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * project = gcp.organizations.get_project()
 * pab_policy = gcp.iam.PrincipalAccessBoundaryPolicy("pab_policy",
 *     organization="123456789",
 *     location="global",
 *     display_name="test project binding",
 *     principal_access_boundary_policy_id="my-pab-policy")
 * my_project_binding = gcp.iam.ProjectsPolicyBinding("my-project-binding",
 *     project=project.project_id,
 *     location="global",
 *     display_name="test project binding",
 *     policy_kind="PRINCIPAL_ACCESS_BOUNDARY",
 *     policy_binding_id="test-project-binding",
 *     policy=pab_policy.principal_access_boundary_policy_id.apply(lambda principal_access_boundary_policy_id: f"organizations/123456789/locations/global/principalAccessBoundaryPolicies/{principal_access_boundary_policy_id}"),
 *     target={
 *         "principal_set": f"//cloudresourcemanager.googleapis.com/projects/{project.project_id}",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var project = Gcp.Organizations.GetProject.Invoke();
 *     var pabPolicy = new Gcp.Iam.PrincipalAccessBoundaryPolicy("pab_policy", new()
 *     {
 *         Organization = "123456789",
 *         Location = "global",
 *         DisplayName = "test project binding",
 *         PrincipalAccessBoundaryPolicyId = "my-pab-policy",
 *     });
 *     var my_project_binding = new Gcp.Iam.ProjectsPolicyBinding("my-project-binding", new()
 *     {
 *         Project = project.Apply(getProjectResult => getProjectResult.ProjectId),
 *         Location = "global",
 *         DisplayName = "test project binding",
 *         PolicyKind = "PRINCIPAL_ACCESS_BOUNDARY",
 *         PolicyBindingId = "test-project-binding",
 *         Policy = pabPolicy.PrincipalAccessBoundaryPolicyId.Apply(principalAccessBoundaryPolicyId => $"organizations/123456789/locations/global/principalAccessBoundaryPolicies/{principalAccessBoundaryPolicyId}"),
 *         Target = new Gcp.Iam.Inputs.ProjectsPolicyBindingTargetArgs
 *         {
 *             PrincipalSet = $"//cloudresourcemanager.googleapis.com/projects/{project.Apply(getProjectResult => getProjectResult.ProjectId)}",
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"fmt"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/iam"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		project, err := organizations.LookupProject(ctx, &organizations.LookupProjectArgs{}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		pabPolicy, err := iam.NewPrincipalAccessBoundaryPolicy(ctx, "pab_policy", &iam.PrincipalAccessBoundaryPolicyArgs{
 * 			Organization:                    pulumi.String("123456789"),
 * 			Location:                        pulumi.String("global"),
 * 			DisplayName:                     pulumi.String("test project binding"),
 * 			PrincipalAccessBoundaryPolicyId: pulumi.String("my-pab-policy"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = iam.NewProjectsPolicyBinding(ctx, "my-project-binding", &iam.ProjectsPolicyBindingArgs{
 * 			Project:         pulumi.String(project.ProjectId),
 * 			Location:        pulumi.String("global"),
 * 			DisplayName:     pulumi.String("test project binding"),
 * 			PolicyKind:      pulumi.String("PRINCIPAL_ACCESS_BOUNDARY"),
 * 			PolicyBindingId: pulumi.String("test-project-binding"),
 * 			Policy: pabPolicy.PrincipalAccessBoundaryPolicyId.ApplyT(func(principalAccessBoundaryPolicyId string) (string, error) {
 * 				return fmt.Sprintf("organizations/123456789/locations/global/principalAccessBoundaryPolicies/%v", principalAccessBoundaryPolicyId), nil
 * 			}).(pulumi.StringOutput),
 * 			Target: &iam.ProjectsPolicyBindingTargetArgs{
 * 				PrincipalSet: pulumi.Sprintf("//cloudresourcemanager.googleapis.com/projects/%v", project.ProjectId),
 * 			},
 * 		})
 * 		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.OrganizationsFunctions;
 * import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
 * import com.pulumi.gcp.iam.PrincipalAccessBoundaryPolicy;
 * import com.pulumi.gcp.iam.PrincipalAccessBoundaryPolicyArgs;
 * import com.pulumi.gcp.iam.ProjectsPolicyBinding;
 * import com.pulumi.gcp.iam.ProjectsPolicyBindingArgs;
 * import com.pulumi.gcp.iam.inputs.ProjectsPolicyBindingTargetArgs;
 * 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) {
 *         final var project = OrganizationsFunctions.getProject();
 *         var pabPolicy = new PrincipalAccessBoundaryPolicy("pabPolicy", PrincipalAccessBoundaryPolicyArgs.builder()
 *             .organization("123456789")
 *             .location("global")
 *             .displayName("test project binding")
 *             .principalAccessBoundaryPolicyId("my-pab-policy")
 *             .build());
 *         var my_project_binding = new ProjectsPolicyBinding("my-project-binding", ProjectsPolicyBindingArgs.builder()
 *             .project(project.applyValue(getProjectResult -> getProjectResult.projectId()))
 *             .location("global")
 *             .displayName("test project binding")
 *             .policyKind("PRINCIPAL_ACCESS_BOUNDARY")
 *             .policyBindingId("test-project-binding")
 *             .policy(pabPolicy.principalAccessBoundaryPolicyId().applyValue(principalAccessBoundaryPolicyId -> String.format("organizations/123456789/locations/global/principalAccessBoundaryPolicies/%s", principalAccessBoundaryPolicyId)))
 *             .target(ProjectsPolicyBindingTargetArgs.builder()
 *                 .principalSet(String.format("//cloudresourcemanager.googleapis.com/projects/%s", project.applyValue(getProjectResult -> getProjectResult.projectId())))
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   pabPolicy:
 *     type: gcp:iam:PrincipalAccessBoundaryPolicy
 *     name: pab_policy
 *     properties:
 *       organization: '123456789'
 *       location: global
 *       displayName: test project binding
 *       principalAccessBoundaryPolicyId: my-pab-policy
 *   my-project-binding:
 *     type: gcp:iam:ProjectsPolicyBinding
 *     properties:
 *       project: ${project.projectId}
 *       location: global
 *       displayName: test project binding
 *       policyKind: PRINCIPAL_ACCESS_BOUNDARY
 *       policyBindingId: test-project-binding
 *       policy: organizations/123456789/locations/global/principalAccessBoundaryPolicies/${pabPolicy.principalAccessBoundaryPolicyId}
 *       target:
 *         principalSet: //cloudresourcemanager.googleapis.com/projects/${project.projectId}
 * variables:
 *   project:
 *     fn::invoke:
 *       function: gcp:organizations:getProject
 *       arguments: {}
 * ```
 * 
 * ## Import
 * ProjectsPolicyBinding can be imported using any of these accepted formats:
 * * `projects/{{project}}/locations/{{location}}/policyBindings/{{policy_binding_id}}`
 * * `{{project}}/{{location}}/{{policy_binding_id}}`
 * * `{{location}}/{{policy_binding_id}}`
 * When using the `pulumi import` command, ProjectsPolicyBinding can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:iam/projectsPolicyBinding:ProjectsPolicyBinding default projects/{{project}}/locations/{{location}}/policyBindings/{{policy_binding_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:iam/projectsPolicyBinding:ProjectsPolicyBinding default {{project}}/{{location}}/{{policy_binding_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:iam/projectsPolicyBinding:ProjectsPolicyBinding default {{location}}/{{policy_binding_id}}
 * ```
 */
public class ProjectsPolicyBinding internal constructor(
    override val javaResource: com.pulumi.gcp.iam.ProjectsPolicyBinding,
) : KotlinCustomResource(javaResource, ProjectsPolicyBindingMapper) {
    /**
     * Optional. User defined annotations. See https://google.aip.dev/148#annotations for more details such as format and size
     * limitations **Note**: This field is non-authoritative, and will only manage the annotations present in your
     * configuration. Please refer to the field 'effective_annotations' for all of the annotations present on the resource.
     */
    public val annotations: Output>?
        get() = javaResource.annotations().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The
     * syntax and semantics of CEL are documented at https://github.com/google/cel-spec. Example (Comparison): title: \"Summary
     * size limit\" description: \"Determines if a summary is less than 100 chars\" expression: \"document.summary.size() <
     * 100\" Example (Equality): title: \"Requestor is owner\" description: \"Determines if requestor is the document owner\"
     * expression: \"document.owner == request.auth.claims.email\" Example (Logic): title: \"Public documents\" description:
     * \"Determine whether the document should be publicly visible\" expression: \"document.type != 'private' && document.type
     * != 'internal'\" Example (Data Manipulation): title: \"Notification string\" description: \"Create a notification string
     * with a timestamp.\" expression: \"'New message received at ' + string(document.create_time)\" The exact variables and
     * functions that may be referenced within an expression are determined by the service that evaluates it. See the service
     * documentation for additional information.
     */
    public val condition: Output?
        get() = javaResource.condition().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    projectsPolicyBindingConditionToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * Output only. The time when the policy binding was created.
     */
    public val createTime: Output
        get() = javaResource.createTime().applyValue({ args0 -> args0 })

    /**
     * Optional. The description of the policy binding. Must be less than or equal to 63 characters.
     */
    public val displayName: Output?
        get() = javaResource.displayName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    public val effectiveAnnotations: Output>
        get() = javaResource.effectiveAnnotations().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * Optional. The etag for the policy binding. If this is provided on update, it must match the server's etag.
     */
    public val etag: Output
        get() = javaResource.etag().applyValue({ args0 -> args0 })

    /**
     * The location of the Policy Binding
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * The name of the policy binding in the format `{binding_parent/locations/{location}/policyBindings/{policy_binding_id}`
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * Required. Immutable. The resource name of the policy to be bound. The binding parent and policy must belong to the same Organization (or Project).
     */
    public val policy: Output
        get() = javaResource.policy().applyValue({ args0 -> args0 })

    /**
     * The Policy Binding ID.
     */
    public val policyBindingId: Output
        get() = javaResource.policyBindingId().applyValue({ args0 -> args0 })

    /**
     * Immutable. The kind of the policy to attach in this binding. This field must be one of the following: - Left empty (will
     * be automatically set to the policy kind) - The input policy kind Possible values: POLICY_KIND_UNSPECIFIED
     * PRINCIPAL_ACCESS_BOUNDARY ACCESS
     */
    public val policyKind: Output?
        get() = javaResource.policyKind().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Output only. The globally unique ID of the policy to be bound.
     */
    public val policyUid: Output
        get() = javaResource.policyUid().applyValue({ args0 -> args0 })

    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * Target is the full resource name of the resource to which the policy will be bound. Immutable once set.
     * Structure is documented below.
     */
    public val target: Output
        get() = javaResource.target().applyValue({ args0 ->
            args0.let({ args0 ->
                projectsPolicyBindingTargetToKotlin(args0)
            })
        })

    /**
     * Output only. The globally unique ID of the policy binding. Assigned when the policy binding is created.
     */
    public val uid: Output
        get() = javaResource.uid().applyValue({ args0 -> args0 })

    /**
     * Output only. The time when the policy binding was most recently updated.
     */
    public val updateTime: Output
        get() = javaResource.updateTime().applyValue({ args0 -> args0 })
}

public object ProjectsPolicyBindingMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.iam.ProjectsPolicyBinding::class == javaResource::class

    override fun map(javaResource: Resource): ProjectsPolicyBinding =
        ProjectsPolicyBinding(javaResource as com.pulumi.gcp.iam.ProjectsPolicyBinding)
}

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy