1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. alloydb
  5. User
Google Cloud v8.23.0 published on Monday, Mar 24, 2025 by Pulumi

gcp.alloydb.User

Explore with Pulumi AI

A database user in an AlloyDB cluster.

To get more information about User, see:

Example Usage

Alloydb User Builtin

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const defaultCluster = new gcp.alloydb.Cluster("default", {
    clusterId: "alloydb-cluster",
    location: "us-central1",
    networkConfig: {
        network: defaultGoogleComputeNetwork.id,
    },
    initialUser: {
        password: "cluster_secret",
    },
});
const defaultNetwork = new gcp.compute.Network("default", {name: "alloydb-network"});
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],
});
Copy
import pulumi
import pulumi_gcp as gcp

default_cluster = gcp.alloydb.Cluster("default",
    cluster_id="alloydb-cluster",
    location="us-central1",
    network_config={
        "network": default_google_compute_network["id"],
    },
    initial_user={
        "password": "cluster_secret",
    })
default_network = gcp.compute.Network("default", name="alloydb-network")
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]))
Copy
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/alloydb"
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/compute"
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/organizations"
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/servicenetworking"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		defaultCluster, err := alloydb.NewCluster(ctx, "default", &alloydb.ClusterArgs{
			ClusterId: pulumi.String("alloydb-cluster"),
			Location:  pulumi.String("us-central1"),
			NetworkConfig: &alloydb.ClusterNetworkConfigArgs{
				Network: pulumi.Any(defaultGoogleComputeNetwork.Id),
			},
			InitialUser: &alloydb.ClusterInitialUserArgs{
				Password: pulumi.String("cluster_secret"),
			},
		})
		if err != nil {
			return err
		}
		defaultNetwork, err := compute.NewNetwork(ctx, "default", &compute.NetworkArgs{
			Name: pulumi.String("alloydb-network"),
		})
		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
		}
		_default, 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, &organizations.LookupProjectArgs{}, 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
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var defaultCluster = new Gcp.Alloydb.Cluster("default", new()
    {
        ClusterId = "alloydb-cluster",
        Location = "us-central1",
        NetworkConfig = new Gcp.Alloydb.Inputs.ClusterNetworkConfigArgs
        {
            Network = defaultGoogleComputeNetwork.Id,
        },
        InitialUser = new Gcp.Alloydb.Inputs.ClusterInitialUserArgs
        {
            Password = "cluster_secret",
        },
    });

    var defaultNetwork = new Gcp.Compute.Network("default", new()
    {
        Name = "alloydb-network",
    });

    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,
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.alloydb.Cluster;
import com.pulumi.gcp.alloydb.ClusterArgs;
import com.pulumi.gcp.alloydb.inputs.ClusterNetworkConfigArgs;
import com.pulumi.gcp.alloydb.inputs.ClusterInitialUserArgs;
import com.pulumi.gcp.compute.Network;
import com.pulumi.gcp.compute.NetworkArgs;
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 defaultCluster = new Cluster("defaultCluster", ClusterArgs.builder()
            .clusterId("alloydb-cluster")
            .location("us-central1")
            .networkConfig(ClusterNetworkConfigArgs.builder()
                .network(defaultGoogleComputeNetwork.id())
                .build())
            .initialUser(ClusterInitialUserArgs.builder()
                .password("cluster_secret")
                .build())
            .build());

        var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
            .name("alloydb-network")
            .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());

    }
}
Copy
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
      networkConfig:
        network: ${defaultGoogleComputeNetwork.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: {}
Copy

Alloydb User Iam

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",
    networkConfig: {
        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: "user2@foo.com",
    userType: "ALLOYDB_IAM_USER",
    databaseRoles: ["alloydbiamuser"],
}, {
    dependsOn: [_default],
});
Copy
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_config={
        "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="user2@foo.com",
    user_type="ALLOYDB_IAM_USER",
    database_roles=["alloydbiamuser"],
    opts = pulumi.ResourceOptions(depends_on=[default]))
Copy
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/alloydb"
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/compute"
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/organizations"
	"github.com/pulumi/pulumi-gcp/sdk/v8/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"),
			NetworkConfig: &alloydb.ClusterNetworkConfigArgs{
				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
		}
		_default, 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, &organizations.LookupProjectArgs{}, nil)
		if err != nil {
			return err
		}
		_, err = alloydb.NewUser(ctx, "user2", &alloydb.UserArgs{
			Cluster:  defaultCluster.Name,
			UserId:   pulumi.String("user2@foo.com"),
			UserType: pulumi.String("ALLOYDB_IAM_USER"),
			DatabaseRoles: pulumi.StringArray{
				pulumi.String("alloydbiamuser"),
			},
		}, pulumi.DependsOn([]pulumi.Resource{
			_default,
		}))
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
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",
        NetworkConfig = new Gcp.Alloydb.Inputs.ClusterNetworkConfigArgs
        {
            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 = "user2@foo.com",
        UserType = "ALLOYDB_IAM_USER",
        DatabaseRoles = new[]
        {
            "alloydbiamuser",
        },
    }, new CustomResourceOptions
    {
        DependsOn =
        {
            @default,
        },
    });

});
Copy
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.ClusterNetworkConfigArgs;
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")
            .networkConfig(ClusterNetworkConfigArgs.builder()
                .network(defaultNetwork.id())
                .build())
            .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("user2@foo.com")
            .userType("ALLOYDB_IAM_USER")
            .databaseRoles("alloydbiamuser")
            .build(), CustomResourceOptions.builder()
                .dependsOn(default_)
                .build());

    }
}
Copy
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
      networkConfig:
        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: user2@foo.com
      userType: ALLOYDB_IAM_USER
      databaseRoles:
        - alloydbiamuser
    options:
      dependsOn:
        - ${default}
variables:
  project:
    fn::invoke:
      function: gcp:organizations:getProject
      arguments: {}
Copy

Create User Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new User(name: string, args: UserArgs, opts?: CustomResourceOptions);
@overload
def User(resource_name: str,
         args: UserArgs,
         opts: Optional[ResourceOptions] = None)

@overload
def User(resource_name: str,
         opts: Optional[ResourceOptions] = None,
         cluster: Optional[str] = None,
         user_id: Optional[str] = None,
         user_type: Optional[str] = None,
         database_roles: Optional[Sequence[str]] = None,
         password: Optional[str] = None)
func NewUser(ctx *Context, name string, args UserArgs, opts ...ResourceOption) (*User, error)
public User(string name, UserArgs args, CustomResourceOptions? opts = null)
public User(String name, UserArgs args)
public User(String name, UserArgs args, CustomResourceOptions options)
type: gcp:alloydb:User
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. UserArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. UserArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. UserArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. UserArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. UserArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var userResource = new Gcp.Alloydb.User("userResource", new()
{
    Cluster = "string",
    UserId = "string",
    UserType = "string",
    DatabaseRoles = new[]
    {
        "string",
    },
    Password = "string",
});
Copy
example, err := alloydb.NewUser(ctx, "userResource", &alloydb.UserArgs{
	Cluster:  pulumi.String("string"),
	UserId:   pulumi.String("string"),
	UserType: pulumi.String("string"),
	DatabaseRoles: pulumi.StringArray{
		pulumi.String("string"),
	},
	Password: pulumi.String("string"),
})
Copy
var userResource = new User("userResource", UserArgs.builder()
    .cluster("string")
    .userId("string")
    .userType("string")
    .databaseRoles("string")
    .password("string")
    .build());
Copy
user_resource = gcp.alloydb.User("userResource",
    cluster="string",
    user_id="string",
    user_type="string",
    database_roles=["string"],
    password="string")
Copy
const userResource = new gcp.alloydb.User("userResource", {
    cluster: "string",
    userId: "string",
    userType: "string",
    databaseRoles: ["string"],
    password: "string",
});
Copy
type: gcp:alloydb:User
properties:
    cluster: string
    databaseRoles:
        - string
    password: string
    userId: string
    userType: string
Copy

User Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The User resource accepts the following input properties:

Cluster
This property is required.
Changes to this property will trigger replacement.
string
Identifies the alloydb cluster. Must be in the format 'projects/{project}/locations/{location}/clusters/{cluster_id}'
UserId
This property is required.
Changes to this property will trigger replacement.
string
The database role name of the user.
UserType
This property is required.
Changes to this property will trigger replacement.
string
The type of this user. Possible values are: ALLOYDB_BUILT_IN, ALLOYDB_IAM_USER.


DatabaseRoles List<string>
List of database roles this database user has.
Password string
Password for this database user. Note: This property is sensitive and will not be displayed in the plan.
Cluster
This property is required.
Changes to this property will trigger replacement.
string
Identifies the alloydb cluster. Must be in the format 'projects/{project}/locations/{location}/clusters/{cluster_id}'
UserId
This property is required.
Changes to this property will trigger replacement.
string
The database role name of the user.
UserType
This property is required.
Changes to this property will trigger replacement.
string
The type of this user. Possible values are: ALLOYDB_BUILT_IN, ALLOYDB_IAM_USER.


DatabaseRoles []string
List of database roles this database user has.
Password string
Password for this database user. Note: This property is sensitive and will not be displayed in the plan.
cluster
This property is required.
Changes to this property will trigger replacement.
String
Identifies the alloydb cluster. Must be in the format 'projects/{project}/locations/{location}/clusters/{cluster_id}'
userId
This property is required.
Changes to this property will trigger replacement.
String
The database role name of the user.
userType
This property is required.
Changes to this property will trigger replacement.
String
The type of this user. Possible values are: ALLOYDB_BUILT_IN, ALLOYDB_IAM_USER.


databaseRoles List<String>
List of database roles this database user has.
password String
Password for this database user. Note: This property is sensitive and will not be displayed in the plan.
cluster
This property is required.
Changes to this property will trigger replacement.
string
Identifies the alloydb cluster. Must be in the format 'projects/{project}/locations/{location}/clusters/{cluster_id}'
userId
This property is required.
Changes to this property will trigger replacement.
string
The database role name of the user.
userType
This property is required.
Changes to this property will trigger replacement.
string
The type of this user. Possible values are: ALLOYDB_BUILT_IN, ALLOYDB_IAM_USER.


databaseRoles string[]
List of database roles this database user has.
password string
Password for this database user. Note: This property is sensitive and will not be displayed in the plan.
cluster
This property is required.
Changes to this property will trigger replacement.
str
Identifies the alloydb cluster. Must be in the format 'projects/{project}/locations/{location}/clusters/{cluster_id}'
user_id
This property is required.
Changes to this property will trigger replacement.
str
The database role name of the user.
user_type
This property is required.
Changes to this property will trigger replacement.
str
The type of this user. Possible values are: ALLOYDB_BUILT_IN, ALLOYDB_IAM_USER.


database_roles Sequence[str]
List of database roles this database user has.
password str
Password for this database user. Note: This property is sensitive and will not be displayed in the plan.
cluster
This property is required.
Changes to this property will trigger replacement.
String
Identifies the alloydb cluster. Must be in the format 'projects/{project}/locations/{location}/clusters/{cluster_id}'
userId
This property is required.
Changes to this property will trigger replacement.
String
The database role name of the user.
userType
This property is required.
Changes to this property will trigger replacement.
String
The type of this user. Possible values are: ALLOYDB_BUILT_IN, ALLOYDB_IAM_USER.


databaseRoles List<String>
List of database roles this database user has.
password String
Password for this database user. Note: This property is sensitive and will not be displayed in the plan.

Outputs

All input properties are implicitly available as output properties. Additionally, the User resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Name string
Name of the resource in the form of projects/{project}/locations/{location}/clusters/{cluster}/users/{user}.
Id string
The provider-assigned unique ID for this managed resource.
Name string
Name of the resource in the form of projects/{project}/locations/{location}/clusters/{cluster}/users/{user}.
id String
The provider-assigned unique ID for this managed resource.
name String
Name of the resource in the form of projects/{project}/locations/{location}/clusters/{cluster}/users/{user}.
id string
The provider-assigned unique ID for this managed resource.
name string
Name of the resource in the form of projects/{project}/locations/{location}/clusters/{cluster}/users/{user}.
id str
The provider-assigned unique ID for this managed resource.
name str
Name of the resource in the form of projects/{project}/locations/{location}/clusters/{cluster}/users/{user}.
id String
The provider-assigned unique ID for this managed resource.
name String
Name of the resource in the form of projects/{project}/locations/{location}/clusters/{cluster}/users/{user}.

Look up Existing User Resource

Get an existing User resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: UserState, opts?: CustomResourceOptions): User
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        cluster: Optional[str] = None,
        database_roles: Optional[Sequence[str]] = None,
        name: Optional[str] = None,
        password: Optional[str] = None,
        user_id: Optional[str] = None,
        user_type: Optional[str] = None) -> User
func GetUser(ctx *Context, name string, id IDInput, state *UserState, opts ...ResourceOption) (*User, error)
public static User Get(string name, Input<string> id, UserState? state, CustomResourceOptions? opts = null)
public static User get(String name, Output<String> id, UserState state, CustomResourceOptions options)
resources:  _:    type: gcp:alloydb:User    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Cluster Changes to this property will trigger replacement. string
Identifies the alloydb cluster. Must be in the format 'projects/{project}/locations/{location}/clusters/{cluster_id}'
DatabaseRoles List<string>
List of database roles this database user has.
Name string
Name of the resource in the form of projects/{project}/locations/{location}/clusters/{cluster}/users/{user}.
Password string
Password for this database user. Note: This property is sensitive and will not be displayed in the plan.
UserId Changes to this property will trigger replacement. string
The database role name of the user.
UserType Changes to this property will trigger replacement. string
The type of this user. Possible values are: ALLOYDB_BUILT_IN, ALLOYDB_IAM_USER.


Cluster Changes to this property will trigger replacement. string
Identifies the alloydb cluster. Must be in the format 'projects/{project}/locations/{location}/clusters/{cluster_id}'
DatabaseRoles []string
List of database roles this database user has.
Name string
Name of the resource in the form of projects/{project}/locations/{location}/clusters/{cluster}/users/{user}.
Password string
Password for this database user. Note: This property is sensitive and will not be displayed in the plan.
UserId Changes to this property will trigger replacement. string
The database role name of the user.
UserType Changes to this property will trigger replacement. string
The type of this user. Possible values are: ALLOYDB_BUILT_IN, ALLOYDB_IAM_USER.


cluster Changes to this property will trigger replacement. String
Identifies the alloydb cluster. Must be in the format 'projects/{project}/locations/{location}/clusters/{cluster_id}'
databaseRoles List<String>
List of database roles this database user has.
name String
Name of the resource in the form of projects/{project}/locations/{location}/clusters/{cluster}/users/{user}.
password String
Password for this database user. Note: This property is sensitive and will not be displayed in the plan.
userId Changes to this property will trigger replacement. String
The database role name of the user.
userType Changes to this property will trigger replacement. String
The type of this user. Possible values are: ALLOYDB_BUILT_IN, ALLOYDB_IAM_USER.


cluster Changes to this property will trigger replacement. string
Identifies the alloydb cluster. Must be in the format 'projects/{project}/locations/{location}/clusters/{cluster_id}'
databaseRoles string[]
List of database roles this database user has.
name string
Name of the resource in the form of projects/{project}/locations/{location}/clusters/{cluster}/users/{user}.
password string
Password for this database user. Note: This property is sensitive and will not be displayed in the plan.
userId Changes to this property will trigger replacement. string
The database role name of the user.
userType Changes to this property will trigger replacement. string
The type of this user. Possible values are: ALLOYDB_BUILT_IN, ALLOYDB_IAM_USER.


cluster Changes to this property will trigger replacement. str
Identifies the alloydb cluster. Must be in the format 'projects/{project}/locations/{location}/clusters/{cluster_id}'
database_roles Sequence[str]
List of database roles this database user has.
name str
Name of the resource in the form of projects/{project}/locations/{location}/clusters/{cluster}/users/{user}.
password str
Password for this database user. Note: This property is sensitive and will not be displayed in the plan.
user_id Changes to this property will trigger replacement. str
The database role name of the user.
user_type Changes to this property will trigger replacement. str
The type of this user. Possible values are: ALLOYDB_BUILT_IN, ALLOYDB_IAM_USER.


cluster Changes to this property will trigger replacement. String
Identifies the alloydb cluster. Must be in the format 'projects/{project}/locations/{location}/clusters/{cluster_id}'
databaseRoles List<String>
List of database roles this database user has.
name String
Name of the resource in the form of projects/{project}/locations/{location}/clusters/{cluster}/users/{user}.
password String
Password for this database user. Note: This property is sensitive and will not be displayed in the plan.
userId Changes to this property will trigger replacement. String
The database role name of the user.
userType Changes to this property will trigger replacement. String
The type of this user. Possible values are: ALLOYDB_BUILT_IN, ALLOYDB_IAM_USER.


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:

$ pulumi import gcp:alloydb/user:User default projects/{{project}}/locations/{{location}}/clusters/{{cluster}}/users/{{user_id}}
Copy
$ pulumi import gcp:alloydb/user:User default {{project}}/{{location}}/{{cluster}}/{{user_id}}
Copy
$ pulumi import gcp:alloydb/user:User default {{location}}/{{cluster}}/{{user_id}}
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Google Cloud (GCP) Classic pulumi/pulumi-gcp
License
Apache-2.0
Notes
This Pulumi package is based on the google-beta Terraform Provider.