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

com.pulumi.gcp.alloydb.kotlin.User.kt Maven / Gradle / Ivy

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

package com.pulumi.gcp.alloydb.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 [User].
 */
@PulumiTagMarker
public class UserResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: UserArgs = UserArgs()

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

/**
 * A database user in an AlloyDB cluster.
 * To get more information about User, see:
 * * [API documentation](https://cloud.google.com/alloydb/docs/reference/rest/v1/projects.locations.clusters.users/create)
 * * How-to Guides
 *     * [AlloyDB](https://cloud.google.com/alloydb/docs/)
 * ## Example Usage
 * ### Alloydb User Builtin
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const defaultNetwork = new gcp.compute.Network("default", {name: "alloydb-network"});
 * const defaultCluster = new gcp.alloydb.Cluster("default", {
 *     clusterId: "alloydb-cluster",
 *     location: "us-central1",
 *     network: defaultNetwork.id,
 *     initialUser: {
 *         password: "cluster_secret",
 *     },
 * });
 * const privateIpAlloc = new gcp.compute.GlobalAddress("private_ip_alloc", {
 *     name: "alloydb-cluster",
 *     addressType: "INTERNAL",
 *     purpose: "VPC_PEERING",
 *     prefixLength: 16,
 *     network: defaultNetwork.id,
 * });
 * const vpcConnection = new gcp.servicenetworking.Connection("vpc_connection", {
 *     network: defaultNetwork.id,
 *     service: "servicenetworking.googleapis.com",
 *     reservedPeeringRanges: [privateIpAlloc.name],
 * });
 * const _default = new gcp.alloydb.Instance("default", {
 *     cluster: defaultCluster.name,
 *     instanceId: "alloydb-instance",
 *     instanceType: "PRIMARY",
 * }, {
 *     dependsOn: [vpcConnection],
 * });
 * const project = gcp.organizations.getProject({});
 * const user1 = new gcp.alloydb.User("user1", {
 *     cluster: defaultCluster.name,
 *     userId: "user1",
 *     userType: "ALLOYDB_BUILT_IN",
 *     password: "user_secret",
 *     databaseRoles: ["alloydbsuperuser"],
 * }, {
 *     dependsOn: [_default],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * default_network = gcp.compute.Network("default", name="alloydb-network")
 * default_cluster = gcp.alloydb.Cluster("default",
 *     cluster_id="alloydb-cluster",
 *     location="us-central1",
 *     network=default_network.id,
 *     initial_user={
 *         "password": "cluster_secret",
 *     })
 * private_ip_alloc = gcp.compute.GlobalAddress("private_ip_alloc",
 *     name="alloydb-cluster",
 *     address_type="INTERNAL",
 *     purpose="VPC_PEERING",
 *     prefix_length=16,
 *     network=default_network.id)
 * vpc_connection = gcp.servicenetworking.Connection("vpc_connection",
 *     network=default_network.id,
 *     service="servicenetworking.googleapis.com",
 *     reserved_peering_ranges=[private_ip_alloc.name])
 * default = gcp.alloydb.Instance("default",
 *     cluster=default_cluster.name,
 *     instance_id="alloydb-instance",
 *     instance_type="PRIMARY",
 *     opts = pulumi.ResourceOptions(depends_on=[vpc_connection]))
 * project = gcp.organizations.get_project()
 * user1 = gcp.alloydb.User("user1",
 *     cluster=default_cluster.name,
 *     user_id="user1",
 *     user_type="ALLOYDB_BUILT_IN",
 *     password="user_secret",
 *     database_roles=["alloydbsuperuser"],
 *     opts = pulumi.ResourceOptions(depends_on=[default]))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var defaultNetwork = new Gcp.Compute.Network("default", new()
 *     {
 *         Name = "alloydb-network",
 *     });
 *     var defaultCluster = new Gcp.Alloydb.Cluster("default", new()
 *     {
 *         ClusterId = "alloydb-cluster",
 *         Location = "us-central1",
 *         Network = defaultNetwork.Id,
 *         InitialUser = new Gcp.Alloydb.Inputs.ClusterInitialUserArgs
 *         {
 *             Password = "cluster_secret",
 *         },
 *     });
 *     var privateIpAlloc = new Gcp.Compute.GlobalAddress("private_ip_alloc", new()
 *     {
 *         Name = "alloydb-cluster",
 *         AddressType = "INTERNAL",
 *         Purpose = "VPC_PEERING",
 *         PrefixLength = 16,
 *         Network = defaultNetwork.Id,
 *     });
 *     var vpcConnection = new Gcp.ServiceNetworking.Connection("vpc_connection", new()
 *     {
 *         Network = defaultNetwork.Id,
 *         Service = "servicenetworking.googleapis.com",
 *         ReservedPeeringRanges = new[]
 *         {
 *             privateIpAlloc.Name,
 *         },
 *     });
 *     var @default = new Gcp.Alloydb.Instance("default", new()
 *     {
 *         Cluster = defaultCluster.Name,
 *         InstanceId = "alloydb-instance",
 *         InstanceType = "PRIMARY",
 *     }, new CustomResourceOptions
 *     {
 *         DependsOn =
 *         {
 *             vpcConnection,
 *         },
 *     });
 *     var project = Gcp.Organizations.GetProject.Invoke();
 *     var user1 = new Gcp.Alloydb.User("user1", new()
 *     {
 *         Cluster = defaultCluster.Name,
 *         UserId = "user1",
 *         UserType = "ALLOYDB_BUILT_IN",
 *         Password = "user_secret",
 *         DatabaseRoles = new[]
 *         {
 *             "alloydbsuperuser",
 *         },
 *     }, new CustomResourceOptions
 *     {
 *         DependsOn =
 *         {
 *             @default,
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/alloydb"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/servicenetworking"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		defaultNetwork, err := compute.NewNetwork(ctx, "default", &compute.NetworkArgs{
 * 			Name: pulumi.String("alloydb-network"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		defaultCluster, err := alloydb.NewCluster(ctx, "default", &alloydb.ClusterArgs{
 * 			ClusterId: pulumi.String("alloydb-cluster"),
 * 			Location:  pulumi.String("us-central1"),
 * 			Network:   defaultNetwork.ID(),
 * 			InitialUser: &alloydb.ClusterInitialUserArgs{
 * 				Password: pulumi.String("cluster_secret"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		privateIpAlloc, err := compute.NewGlobalAddress(ctx, "private_ip_alloc", &compute.GlobalAddressArgs{
 * 			Name:         pulumi.String("alloydb-cluster"),
 * 			AddressType:  pulumi.String("INTERNAL"),
 * 			Purpose:      pulumi.String("VPC_PEERING"),
 * 			PrefixLength: pulumi.Int(16),
 * 			Network:      defaultNetwork.ID(),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		vpcConnection, err := servicenetworking.NewConnection(ctx, "vpc_connection", &servicenetworking.ConnectionArgs{
 * 			Network: defaultNetwork.ID(),
 * 			Service: pulumi.String("servicenetworking.googleapis.com"),
 * 			ReservedPeeringRanges: pulumi.StringArray{
 * 				privateIpAlloc.Name,
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = alloydb.NewInstance(ctx, "default", &alloydb.InstanceArgs{
 * 			Cluster:      defaultCluster.Name,
 * 			InstanceId:   pulumi.String("alloydb-instance"),
 * 			InstanceType: pulumi.String("PRIMARY"),
 * 		}, pulumi.DependsOn([]pulumi.Resource{
 * 			vpcConnection,
 * 		}))
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = organizations.LookupProject(ctx, nil, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = alloydb.NewUser(ctx, "user1", &alloydb.UserArgs{
 * 			Cluster:  defaultCluster.Name,
 * 			UserId:   pulumi.String("user1"),
 * 			UserType: pulumi.String("ALLOYDB_BUILT_IN"),
 * 			Password: pulumi.String("user_secret"),
 * 			DatabaseRoles: pulumi.StringArray{
 * 				pulumi.String("alloydbsuperuser"),
 * 			},
 * 		}, pulumi.DependsOn([]pulumi.Resource{
 * 			_default,
 * 		}))
 * 		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.compute.Network;
 * import com.pulumi.gcp.compute.NetworkArgs;
 * import com.pulumi.gcp.alloydb.Cluster;
 * import com.pulumi.gcp.alloydb.ClusterArgs;
 * import com.pulumi.gcp.alloydb.inputs.ClusterInitialUserArgs;
 * import com.pulumi.gcp.compute.GlobalAddress;
 * import com.pulumi.gcp.compute.GlobalAddressArgs;
 * import com.pulumi.gcp.servicenetworking.Connection;
 * import com.pulumi.gcp.servicenetworking.ConnectionArgs;
 * import com.pulumi.gcp.alloydb.Instance;
 * import com.pulumi.gcp.alloydb.InstanceArgs;
 * import com.pulumi.gcp.organizations.OrganizationsFunctions;
 * import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
 * import com.pulumi.gcp.alloydb.User;
 * import com.pulumi.gcp.alloydb.UserArgs;
 * import com.pulumi.resources.CustomResourceOptions;
 * 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 defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
 *             .name("alloydb-network")
 *             .build());
 *         var defaultCluster = new Cluster("defaultCluster", ClusterArgs.builder()
 *             .clusterId("alloydb-cluster")
 *             .location("us-central1")
 *             .network(defaultNetwork.id())
 *             .initialUser(ClusterInitialUserArgs.builder()
 *                 .password("cluster_secret")
 *                 .build())
 *             .build());
 *         var privateIpAlloc = new GlobalAddress("privateIpAlloc", GlobalAddressArgs.builder()
 *             .name("alloydb-cluster")
 *             .addressType("INTERNAL")
 *             .purpose("VPC_PEERING")
 *             .prefixLength(16)
 *             .network(defaultNetwork.id())
 *             .build());
 *         var vpcConnection = new Connection("vpcConnection", ConnectionArgs.builder()
 *             .network(defaultNetwork.id())
 *             .service("servicenetworking.googleapis.com")
 *             .reservedPeeringRanges(privateIpAlloc.name())
 *             .build());
 *         var default_ = new Instance("default", InstanceArgs.builder()
 *             .cluster(defaultCluster.name())
 *             .instanceId("alloydb-instance")
 *             .instanceType("PRIMARY")
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(vpcConnection)
 *                 .build());
 *         final var project = OrganizationsFunctions.getProject();
 *         var user1 = new User("user1", UserArgs.builder()
 *             .cluster(defaultCluster.name())
 *             .userId("user1")
 *             .userType("ALLOYDB_BUILT_IN")
 *             .password("user_secret")
 *             .databaseRoles("alloydbsuperuser")
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(default_)
 *                 .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   default:
 *     type: gcp:alloydb:Instance
 *     properties:
 *       cluster: ${defaultCluster.name}
 *       instanceId: alloydb-instance
 *       instanceType: PRIMARY
 *     options:
 *       dependson:
 *         - ${vpcConnection}
 *   defaultCluster:
 *     type: gcp:alloydb:Cluster
 *     name: default
 *     properties:
 *       clusterId: alloydb-cluster
 *       location: us-central1
 *       network: ${defaultNetwork.id}
 *       initialUser:
 *         password: cluster_secret
 *   defaultNetwork:
 *     type: gcp:compute:Network
 *     name: default
 *     properties:
 *       name: alloydb-network
 *   privateIpAlloc:
 *     type: gcp:compute:GlobalAddress
 *     name: private_ip_alloc
 *     properties:
 *       name: alloydb-cluster
 *       addressType: INTERNAL
 *       purpose: VPC_PEERING
 *       prefixLength: 16
 *       network: ${defaultNetwork.id}
 *   vpcConnection:
 *     type: gcp:servicenetworking:Connection
 *     name: vpc_connection
 *     properties:
 *       network: ${defaultNetwork.id}
 *       service: servicenetworking.googleapis.com
 *       reservedPeeringRanges:
 *         - ${privateIpAlloc.name}
 *   user1:
 *     type: gcp:alloydb:User
 *     properties:
 *       cluster: ${defaultCluster.name}
 *       userId: user1
 *       userType: ALLOYDB_BUILT_IN
 *       password: user_secret
 *       databaseRoles:
 *         - alloydbsuperuser
 *     options:
 *       dependson:
 *         - ${default}
 * variables:
 *   project:
 *     fn::invoke:
 *       Function: gcp:organizations:getProject
 *       Arguments: {}
 * ```
 * 
 * ### Alloydb User Iam
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const defaultNetwork = new gcp.compute.Network("default", {name: "alloydb-network"});
 * const defaultCluster = new gcp.alloydb.Cluster("default", {
 *     clusterId: "alloydb-cluster",
 *     location: "us-central1",
 *     network: defaultNetwork.id,
 *     initialUser: {
 *         password: "cluster_secret",
 *     },
 * });
 * const privateIpAlloc = new gcp.compute.GlobalAddress("private_ip_alloc", {
 *     name: "alloydb-cluster",
 *     addressType: "INTERNAL",
 *     purpose: "VPC_PEERING",
 *     prefixLength: 16,
 *     network: defaultNetwork.id,
 * });
 * const vpcConnection = new gcp.servicenetworking.Connection("vpc_connection", {
 *     network: defaultNetwork.id,
 *     service: "servicenetworking.googleapis.com",
 *     reservedPeeringRanges: [privateIpAlloc.name],
 * });
 * const _default = new gcp.alloydb.Instance("default", {
 *     cluster: defaultCluster.name,
 *     instanceId: "alloydb-instance",
 *     instanceType: "PRIMARY",
 * }, {
 *     dependsOn: [vpcConnection],
 * });
 * const project = gcp.organizations.getProject({});
 * const user2 = new gcp.alloydb.User("user2", {
 *     cluster: defaultCluster.name,
 *     userId: "[email protected]",
 *     userType: "ALLOYDB_IAM_USER",
 *     databaseRoles: ["alloydbiamuser"],
 * }, {
 *     dependsOn: [_default],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * default_network = gcp.compute.Network("default", name="alloydb-network")
 * default_cluster = gcp.alloydb.Cluster("default",
 *     cluster_id="alloydb-cluster",
 *     location="us-central1",
 *     network=default_network.id,
 *     initial_user={
 *         "password": "cluster_secret",
 *     })
 * private_ip_alloc = gcp.compute.GlobalAddress("private_ip_alloc",
 *     name="alloydb-cluster",
 *     address_type="INTERNAL",
 *     purpose="VPC_PEERING",
 *     prefix_length=16,
 *     network=default_network.id)
 * vpc_connection = gcp.servicenetworking.Connection("vpc_connection",
 *     network=default_network.id,
 *     service="servicenetworking.googleapis.com",
 *     reserved_peering_ranges=[private_ip_alloc.name])
 * default = gcp.alloydb.Instance("default",
 *     cluster=default_cluster.name,
 *     instance_id="alloydb-instance",
 *     instance_type="PRIMARY",
 *     opts = pulumi.ResourceOptions(depends_on=[vpc_connection]))
 * project = gcp.organizations.get_project()
 * user2 = gcp.alloydb.User("user2",
 *     cluster=default_cluster.name,
 *     user_id="[email protected]",
 *     user_type="ALLOYDB_IAM_USER",
 *     database_roles=["alloydbiamuser"],
 *     opts = pulumi.ResourceOptions(depends_on=[default]))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var defaultNetwork = new Gcp.Compute.Network("default", new()
 *     {
 *         Name = "alloydb-network",
 *     });
 *     var defaultCluster = new Gcp.Alloydb.Cluster("default", new()
 *     {
 *         ClusterId = "alloydb-cluster",
 *         Location = "us-central1",
 *         Network = defaultNetwork.Id,
 *         InitialUser = new Gcp.Alloydb.Inputs.ClusterInitialUserArgs
 *         {
 *             Password = "cluster_secret",
 *         },
 *     });
 *     var privateIpAlloc = new Gcp.Compute.GlobalAddress("private_ip_alloc", new()
 *     {
 *         Name = "alloydb-cluster",
 *         AddressType = "INTERNAL",
 *         Purpose = "VPC_PEERING",
 *         PrefixLength = 16,
 *         Network = defaultNetwork.Id,
 *     });
 *     var vpcConnection = new Gcp.ServiceNetworking.Connection("vpc_connection", new()
 *     {
 *         Network = defaultNetwork.Id,
 *         Service = "servicenetworking.googleapis.com",
 *         ReservedPeeringRanges = new[]
 *         {
 *             privateIpAlloc.Name,
 *         },
 *     });
 *     var @default = new Gcp.Alloydb.Instance("default", new()
 *     {
 *         Cluster = defaultCluster.Name,
 *         InstanceId = "alloydb-instance",
 *         InstanceType = "PRIMARY",
 *     }, new CustomResourceOptions
 *     {
 *         DependsOn =
 *         {
 *             vpcConnection,
 *         },
 *     });
 *     var project = Gcp.Organizations.GetProject.Invoke();
 *     var user2 = new Gcp.Alloydb.User("user2", new()
 *     {
 *         Cluster = defaultCluster.Name,
 *         UserId = "[email protected]",
 *         UserType = "ALLOYDB_IAM_USER",
 *         DatabaseRoles = new[]
 *         {
 *             "alloydbiamuser",
 *         },
 *     }, new CustomResourceOptions
 *     {
 *         DependsOn =
 *         {
 *             @default,
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/alloydb"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/servicenetworking"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		defaultNetwork, err := compute.NewNetwork(ctx, "default", &compute.NetworkArgs{
 * 			Name: pulumi.String("alloydb-network"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		defaultCluster, err := alloydb.NewCluster(ctx, "default", &alloydb.ClusterArgs{
 * 			ClusterId: pulumi.String("alloydb-cluster"),
 * 			Location:  pulumi.String("us-central1"),
 * 			Network:   defaultNetwork.ID(),
 * 			InitialUser: &alloydb.ClusterInitialUserArgs{
 * 				Password: pulumi.String("cluster_secret"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		privateIpAlloc, err := compute.NewGlobalAddress(ctx, "private_ip_alloc", &compute.GlobalAddressArgs{
 * 			Name:         pulumi.String("alloydb-cluster"),
 * 			AddressType:  pulumi.String("INTERNAL"),
 * 			Purpose:      pulumi.String("VPC_PEERING"),
 * 			PrefixLength: pulumi.Int(16),
 * 			Network:      defaultNetwork.ID(),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		vpcConnection, err := servicenetworking.NewConnection(ctx, "vpc_connection", &servicenetworking.ConnectionArgs{
 * 			Network: defaultNetwork.ID(),
 * 			Service: pulumi.String("servicenetworking.googleapis.com"),
 * 			ReservedPeeringRanges: pulumi.StringArray{
 * 				privateIpAlloc.Name,
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = alloydb.NewInstance(ctx, "default", &alloydb.InstanceArgs{
 * 			Cluster:      defaultCluster.Name,
 * 			InstanceId:   pulumi.String("alloydb-instance"),
 * 			InstanceType: pulumi.String("PRIMARY"),
 * 		}, pulumi.DependsOn([]pulumi.Resource{
 * 			vpcConnection,
 * 		}))
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = organizations.LookupProject(ctx, nil, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = alloydb.NewUser(ctx, "user2", &alloydb.UserArgs{
 * 			Cluster:  defaultCluster.Name,
 * 			UserId:   pulumi.String("[email protected]"),
 * 			UserType: pulumi.String("ALLOYDB_IAM_USER"),
 * 			DatabaseRoles: pulumi.StringArray{
 * 				pulumi.String("alloydbiamuser"),
 * 			},
 * 		}, pulumi.DependsOn([]pulumi.Resource{
 * 			_default,
 * 		}))
 * 		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.compute.Network;
 * import com.pulumi.gcp.compute.NetworkArgs;
 * import com.pulumi.gcp.alloydb.Cluster;
 * import com.pulumi.gcp.alloydb.ClusterArgs;
 * import com.pulumi.gcp.alloydb.inputs.ClusterInitialUserArgs;
 * import com.pulumi.gcp.compute.GlobalAddress;
 * import com.pulumi.gcp.compute.GlobalAddressArgs;
 * import com.pulumi.gcp.servicenetworking.Connection;
 * import com.pulumi.gcp.servicenetworking.ConnectionArgs;
 * import com.pulumi.gcp.alloydb.Instance;
 * import com.pulumi.gcp.alloydb.InstanceArgs;
 * import com.pulumi.gcp.organizations.OrganizationsFunctions;
 * import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
 * import com.pulumi.gcp.alloydb.User;
 * import com.pulumi.gcp.alloydb.UserArgs;
 * import com.pulumi.resources.CustomResourceOptions;
 * 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 defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
 *             .name("alloydb-network")
 *             .build());
 *         var defaultCluster = new Cluster("defaultCluster", ClusterArgs.builder()
 *             .clusterId("alloydb-cluster")
 *             .location("us-central1")
 *             .network(defaultNetwork.id())
 *             .initialUser(ClusterInitialUserArgs.builder()
 *                 .password("cluster_secret")
 *                 .build())
 *             .build());
 *         var privateIpAlloc = new GlobalAddress("privateIpAlloc", GlobalAddressArgs.builder()
 *             .name("alloydb-cluster")
 *             .addressType("INTERNAL")
 *             .purpose("VPC_PEERING")
 *             .prefixLength(16)
 *             .network(defaultNetwork.id())
 *             .build());
 *         var vpcConnection = new Connection("vpcConnection", ConnectionArgs.builder()
 *             .network(defaultNetwork.id())
 *             .service("servicenetworking.googleapis.com")
 *             .reservedPeeringRanges(privateIpAlloc.name())
 *             .build());
 *         var default_ = new Instance("default", InstanceArgs.builder()
 *             .cluster(defaultCluster.name())
 *             .instanceId("alloydb-instance")
 *             .instanceType("PRIMARY")
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(vpcConnection)
 *                 .build());
 *         final var project = OrganizationsFunctions.getProject();
 *         var user2 = new User("user2", UserArgs.builder()
 *             .cluster(defaultCluster.name())
 *             .userId("[email protected]")
 *             .userType("ALLOYDB_IAM_USER")
 *             .databaseRoles("alloydbiamuser")
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(default_)
 *                 .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   default:
 *     type: gcp:alloydb:Instance
 *     properties:
 *       cluster: ${defaultCluster.name}
 *       instanceId: alloydb-instance
 *       instanceType: PRIMARY
 *     options:
 *       dependson:
 *         - ${vpcConnection}
 *   defaultCluster:
 *     type: gcp:alloydb:Cluster
 *     name: default
 *     properties:
 *       clusterId: alloydb-cluster
 *       location: us-central1
 *       network: ${defaultNetwork.id}
 *       initialUser:
 *         password: cluster_secret
 *   defaultNetwork:
 *     type: gcp:compute:Network
 *     name: default
 *     properties:
 *       name: alloydb-network
 *   privateIpAlloc:
 *     type: gcp:compute:GlobalAddress
 *     name: private_ip_alloc
 *     properties:
 *       name: alloydb-cluster
 *       addressType: INTERNAL
 *       purpose: VPC_PEERING
 *       prefixLength: 16
 *       network: ${defaultNetwork.id}
 *   vpcConnection:
 *     type: gcp:servicenetworking:Connection
 *     name: vpc_connection
 *     properties:
 *       network: ${defaultNetwork.id}
 *       service: servicenetworking.googleapis.com
 *       reservedPeeringRanges:
 *         - ${privateIpAlloc.name}
 *   user2:
 *     type: gcp:alloydb:User
 *     properties:
 *       cluster: ${defaultCluster.name}
 *       userId: [email protected]
 *       userType: ALLOYDB_IAM_USER
 *       databaseRoles:
 *         - alloydbiamuser
 *     options:
 *       dependson:
 *         - ${default}
 * variables:
 *   project:
 *     fn::invoke:
 *       Function: gcp:organizations:getProject
 *       Arguments: {}
 * ```
 * 
 * ## Import
 * User can be imported using any of these accepted formats:
 * * `projects/{{project}}/locations/{{location}}/clusters/{{cluster}}/users/{{user_id}}`
 * * `{{project}}/{{location}}/{{cluster}}/{{user_id}}`
 * * `{{location}}/{{cluster}}/{{user_id}}`
 * When using the `pulumi import` command, User can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:alloydb/user:User default projects/{{project}}/locations/{{location}}/clusters/{{cluster}}/users/{{user_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:alloydb/user:User default {{project}}/{{location}}/{{cluster}}/{{user_id}}
 * ```
 * ```sh
 * $ pulumi import gcp:alloydb/user:User default {{location}}/{{cluster}}/{{user_id}}
 * ```
 */
public class User internal constructor(
    override val javaResource: com.pulumi.gcp.alloydb.User,
) : KotlinCustomResource(javaResource, UserMapper) {
    /**
     * Identifies the alloydb cluster. Must be in the format
     * 'projects/{project}/locations/{location}/clusters/{cluster_id}'
     */
    public val cluster: Output
        get() = javaResource.cluster().applyValue({ args0 -> args0 })

    /**
     * List of database roles this database user has.
     */
    public val databaseRoles: Output>?
        get() = javaResource.databaseRoles().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0 })
            }).orElse(null)
        })

    /**
     * Name of the resource in the form of projects/{project}/locations/{location}/clusters/{cluster}/users/{user}.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * Password for this database user.
     */
    public val password: Output?
        get() = javaResource.password().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The database role name of the user.
     */
    public val userId: Output
        get() = javaResource.userId().applyValue({ args0 -> args0 })

    /**
     * The type of this user.
     * Possible values are: `ALLOYDB_BUILT_IN`, `ALLOYDB_IAM_USER`.
     * - - -
     */
    public val userType: Output
        get() = javaResource.userType().applyValue({ args0 -> args0 })
}

public object UserMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.alloydb.User::class == javaResource::class

    override fun map(javaResource: Resource): User = User(javaResource as com.pulumi.gcp.alloydb.User)
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy