A database user in an AlloyDB cluster.
To get more information about User, see:
resource "google_alloydb_instance" "default" {
cluster = google_alloydb_cluster.default.name
instance_id = "alloydb-instance"
instance_type = "PRIMARY"
depends_on = [google_service_networking_connection.vpc_connection]
}
resource "google_alloydb_cluster" "default" {
cluster_id = "alloydb-cluster"
location = "us-central1"
network = google_compute_network.default.id
initial_user {
password = "cluster_secret"
}
}
data "google_project" "project" {}
resource "google_compute_network" "default" {
name = "alloydb-network"
}
resource "google_compute_global_address" "private_ip_alloc" {
name = "alloydb-cluster"
address_type = "INTERNAL"
purpose = "VPC_PEERING"
prefix_length = 16
network = google_compute_network.default.id
}
resource "google_service_networking_connection" "vpc_connection" {
network = google_compute_network.default.id
service = "servicenetworking.googleapis.com"
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
}
resource "google_alloydb_user" "user1" {
cluster = google_alloydb_cluster.default.name
user_id = "user1"
user_type = "ALLOYDB_BUILT_IN"
password = "user_secret"
database_roles = ["alloydbsuperuser"]
depends_on = [google_alloydb_instance.default]
}
resource "google_alloydb_instance" "default" {
cluster = google_alloydb_cluster.default.name
instance_id = "alloydb-instance"
instance_type = "PRIMARY"
depends_on = [google_service_networking_connection.vpc_connection]
}
resource "google_alloydb_cluster" "default" {
cluster_id = "alloydb-cluster"
location = "us-central1"
network = google_compute_network.default.id
initial_user {
password = "cluster_secret"
}
}
data "google_project" "project" {}
resource "google_compute_network" "default" {
name = "alloydb-network"
}
resource "google_compute_global_address" "private_ip_alloc" {
name = "alloydb-cluster"
address_type = "INTERNAL"
purpose = "VPC_PEERING"
prefix_length = 16
network = google_compute_network.default.id
}
resource "google_service_networking_connection" "vpc_connection" {
network = google_compute_network.default.id
service = "servicenetworking.googleapis.com"
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
}
resource "google_alloydb_user" "user2" {
cluster = google_alloydb_cluster.default.name
user_id = "user2@foo.com"
user_type = "ALLOYDB_IAM_USER"
database_roles = ["alloydbiamuser"]
depends_on = [google_alloydb_instance.default]
}
The following arguments are supported:
cluster
-
(Required)
Identifies the alloydb cluster. Must be in the format
'projects/{project}/locations/{location}/clusters/{cluster_id}'
user_id
-
(Required)
The database role name of the user.
user_type
-
(Required)
The type of this user.
Possible values are: ALLOYDB_BUILT_IN
, ALLOYDB_IAM_USER
.
password
-
(Optional)
Password for this database user.
database_roles
-
(Optional)
List of database roles this database user has.
In addition to the arguments listed above, the following computed attributes are exported:
id
- an identifier for the resource with format {{cluster}}/users/{{user_id}}
name
-
Name of the resource in the form of projects/{project}/locations/{location}/clusters/{cluster}/users/{user}.
This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.update
- Default is 20 minutes.delete
- Default is 20 minutes.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}}
In Terraform v1.5.0 and later, use an import
block to import User using one of the formats above. For example:
import {
id = "projects/{{project}}/locations/{{location}}/clusters/{{cluster}}/users/{{user_id}}"
to = google_alloydb_user.default
}
When using the terraform import
command, User can be imported using one of the formats above. For example:
$ terraform import google_alloydb_user.default projects/{{project}}/locations/{{location}}/clusters/{{cluster}}/users/{{user_id}}
$ terraform import google_alloydb_user.default {{project}}/{{location}}/{{cluster}}/{{user_id}}
$ terraform import google_alloydb_user.default {{location}}/{{cluster}}/{{user_id}}