Skip to content

googleAlloydbInstance

A managed alloydb cluster instance.

To get more information about Instance, see:

Example Usage - Alloydb Instance Basic

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleComputeNetworkDefault = new google.computeNetwork.ComputeNetwork(
  this,
  "default",
  {
    name: "alloydb-cluster",
  }
);
const dataGoogleProjectProject = new google.dataGoogleProject.DataGoogleProject(
  this,
  "project",
  {}
);
const googleAlloydbClusterDefault = new google.alloydbCluster.AlloydbCluster(
  this,
  "default_2",
  {
    cluster_id: "alloydb-cluster",
    initial_user: [
      {
        password: "alloydb-cluster",
      },
    ],
    location: "us-central1",
    network: `projects/\${${dataGoogleProjectProject.number}}/global/networks/\${${googleComputeNetworkDefault.name}}`,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleAlloydbClusterDefault.overrideLogicalId("default");
const googleComputeGlobalAddressPrivateIpAlloc =
  new google.computeGlobalAddress.ComputeGlobalAddress(
    this,
    "private_ip_alloc",
    {
      address_type: "INTERNAL",
      name: "alloydb-cluster",
      network: googleComputeNetworkDefault.id,
      prefix_length: 16,
      purpose: "VPC_PEERING",
    }
  );
const googleServiceNetworkingConnectionVpcConnection =
  new google.serviceNetworkingConnection.ServiceNetworkingConnection(
    this,
    "vpc_connection",
    {
      network: googleComputeNetworkDefault.id,
      reserved_peering_ranges: [googleComputeGlobalAddressPrivateIpAlloc.name],
      service: "servicenetworking.googleapis.com",
    }
  );
const googleAlloydbInstanceDefault = new google.alloydbInstance.AlloydbInstance(
  this,
  "default_5",
  {
    cluster: googleAlloydbClusterDefault.name,
    depends_on: [`\${${googleServiceNetworkingConnectionVpcConnection.fqn}}`],
    instance_id: "alloydb-instance",
    instance_type: "PRIMARY",
    machine_config: [
      {
        cpu_count: 2,
      },
    ],
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleAlloydbInstanceDefault.overrideLogicalId("default");

Argument Reference

The following arguments are supported:

  • instanceType - (Required) The type of the instance. Possible values are primary and readPool.

  • cluster - (Required) Identifies the alloydb cluster. Must be in the format 'projects/{project}/locations/{location}/clusters/{cluster_id}'

  • instanceId - (Required) The ID of the alloydb instance.


  • labels - (Optional) User-defined labels for the alloydb instance.

  • annotations - (Optional) Annotations to allow client tools to store small amount of arbitrary data. This is distinct from labels.

  • displayName - (Optional) User-settable and human-readable display name for the Instance.

  • gceZone - (Optional) The Compute Engine zone that the instance should serve from, per https://cloud.google.com/compute/docs/regions-zones This can ONLY be specified for ZONAL instances. If present for a REGIONAL instance, an error will be thrown. If this is absent for a ZONAL instance, instance is created in a random zone with available capacity.

  • databaseFlags - (Optional) Database flags. Set at instance level. * They are copied from primary instance on read instance creation. * Read instances can set new or override existing flags that are relevant for reads, e.g. for enabling columnar cache on a read instance. Flags set on read instance may or may not be present on primary.

  • availabilityType - (Optional) Availability type of an Instance. Defaults to REGIONAL for both primary and read instances. Note that primary and read instances can have different availability types. Possible values are availabilityTypeUnspecified, zonal, and regional.

  • readPoolConfig - (Optional) Read pool specific config. Structure is documented below.

  • machineConfig - (Optional) Configurations for the machines that host the underlying database engine. Structure is documented below.

The readPoolConfig block supports:

  • nodeCount - (Optional) Read capacity, i.e. number of nodes in a read pool instance.

The machineConfig block supports:

  • cpuCount - (Optional) The number of CPU's in the VM instance.

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format {{cluster}}/instances/{{instanceId}}

  • name - The name of the instance resource.

  • createTime - Time the Instance was created in UTC.

  • updateTime - Time the Instance was updated in UTC.

  • uid - The system-generated UID of the resource.

  • state - The current state of the alloydb instance.

  • reconciling - Set to true if the current state of Instance does not match the user's intended state, and the service is actively updating the resource to reconcile them. This can happen due to user-triggered updates or system actions like failover or maintenance.

  • ipAddress - The IP address for the Instance. This is the connection endpoint for an end-user application.

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 20 minutes.
  • update - Default is 20 minutes.
  • delete - Default is 20 minutes.

Import

Instance can be imported using any of these accepted formats:

$ terraform import google_alloydb_instance.default {{cluster}}/instances/{{instance_id}}
$ terraform import google_alloydb_instance.default {{cluster}}/{{instance_id}}