Skip to content

googleAlloydbCluster

A managed alloydb cluster.

To get more information about Cluster, see:

\~> Warning: All arguments including initialUserPassword will be stored in the raw state as plain-text. Read more about sensitive data in state.

Example Usage - Alloydb Cluster 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",
    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");

Example Usage - Alloydb Cluster Full

/*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-full",
  }
);
const dataGoogleProjectProject = new google.dataGoogleProject.DataGoogleProject(
  this,
  "project",
  {}
);
new google.alloydbCluster.AlloydbCluster(this, "full", {
  automated_backup_policy: [
    {
      backup_window: "1800s",
      enabled: true,
      labels: [
        {
          test: "alloydb-cluster-full",
        },
      ],
      location: "us-central1",
      quantity_based_retention: [
        {
          count: 1,
        },
      ],
      weekly_schedule: [
        {
          days_of_week: ["MONDAY"],
          start_times: [
            {
              hours: 23,
              minutes: 0,
              nanos: 0,
              seconds: 0,
            },
          ],
        },
      ],
    },
  ],
  cluster_id: "alloydb-cluster-full",
  initial_user: [
    {
      password: "alloydb-cluster-full",
      user: "alloydb-cluster-full",
    },
  ],
  labels: [
    {
      test: "alloydb-cluster-full",
    },
  ],
  location: "us-central1",
  network: `projects/\${${dataGoogleProjectProject.number}}/global/networks/\${${googleComputeNetworkDefault.name}}`,
});

Argument Reference

The following arguments are supported:

  • network - (Required) The relative resource name of the VPC network on which the instance can be accessed. It is specified in the following form: "projects/{projectNumber}/global/networks/{network_id}".

  • clusterId - (Required) The ID of the alloydb cluster.


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

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

  • initialUser - (Optional) Initial user to setup during cluster creation. Structure is documented below.

  • automatedBackupPolicy - (Optional) The automated backup policy for this cluster. If no policy is provided then the default policy will be used. The default policy takes one backup a day, has a backup window of 1 hour, and retains backups for 14 days. Structure is documented below.

  • location - (Optional) The location where the alloydb cluster should reside.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

The initialUser block supports:

  • user - (Optional) The database username.

  • password - (Required) The initial password for the user. Note: This property is sensitive and will not be displayed in the plan.

The automatedBackupPolicy block supports:

  • backupWindow - (Optional) The length of the time window during which a backup can be taken. If a backup does not succeed within this time window, it will be canceled and considered failed. The backup window must be at least 5 minutes long. There is no upper bound on the window. If not set, it will default to 1 hour. A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".

  • location - (Optional) The location where the backup will be stored. Currently, the only supported option is to store the backup in the same region as the cluster.

  • labels - (Optional) Labels to apply to backups created using this configuration.

  • weeklySchedule - (Required) Weekly schedule for the Backup. Structure is documented below.

  • timeBasedRetention - (Optional) Time-based Backup retention policy. Structure is documented below.

  • quantityBasedRetention - (Optional) Quantity-based Backup retention policy to retain recent backups. Structure is documented below.

  • enabled - (Optional) Whether automated backups are enabled.

The weeklySchedule block supports:

  • daysOfWeek - (Optional) The days of the week to perform a backup. At least one day of the week must be provided. Each value may be one of monday, tuesday, wednesday, thursday, friday, saturday, and sunday.

  • startTimes - (Required) The times during the day to start a backup. At least one start time must be provided. The start times are assumed to be in UTC and to be an exact hour (e.g., 04:00:00). Structure is documented below.

The startTimes block supports:

  • hours - (Optional) Hours of day in 24 hour format. Should be from 0 to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.

  • minutes - (Optional) Minutes of hour of day. Must be from 0 to 59.

  • seconds - (Optional) Seconds of minutes of the time. Must normally be from 0 to 59. An API may allow the value 60 if it allows leap-seconds.

  • nanos - (Optional) Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.

The timeBasedRetention block supports:

  • retentionPeriod - (Optional) The retention period. A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".

The quantityBasedRetention block supports:

  • count - (Optional) The number of backups to retain.

Attributes Reference

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

  • id - an identifier for the resource with format projects/{{project}}/locations/{{location}}/clusters/{{clusterId}}

  • name - The name of the cluster resource.

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

  • databaseVersion - The database engine major version. This is an output-only field and it's populated at the Cluster creation time. This field cannot be changed after cluster creation.

  • backupSource - Cluster created from backup. Structure is documented below.

  • migrationSource - Cluster created via DMS migration. Structure is documented below.

The backupSource block contains:

  • backupName - (Optional) The name of the backup resource.

The migrationSource block contains:

  • hostPort - (Optional) The host and port of the on-premises instance in host:port format

  • referenceId - (Optional) Place holder for the external source identifier(e.g DMS job name) that created the cluster.

  • sourceType - (Optional) Type of migration source.

Timeouts

This resource provides the following Timeouts configuration options:

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

Import

Cluster can be imported using any of these accepted formats:

$ terraform import google_alloydb_cluster.default projects/{{project}}/locations/{{location}}/clusters/{{cluster_id}}
$ terraform import google_alloydb_cluster.default {{project}}/{{location}}/{{cluster_id}}
$ terraform import google_alloydb_cluster.default {{location}}/{{cluster_id}}
$ terraform import google_alloydb_cluster.default {{cluster_id}}

User Project Overrides

This resource supports User Project Overrides.