instances
Creates, updates, deletes, gets or lists an instances resource.
Overview
| Name | instances |
| Type | Resource |
| Id | google.alloydb.instances |
Fields
The following fields are returned by SELECT queries:
- get
- list
| Name | Datatype | Description |
|---|---|---|
name | string | Output only. The name of the instance resource with the format: * projects/{project}/locations/{region}/clusters/{cluster_id}/instances/{instance_id} where the cluster and instance ID segments should satisfy the regex expression [a-z]([a-z0-9-]{0,61}[a-z0-9])?, e.g. 1-63 characters of lowercase letters, numbers, and dashes, starting with a letter, and ending with a letter or number. For more details see https://google.aip.dev/122. The prefix of the instance resource name is the name of the parent resource: * projects/{project}/locations/{region}/clusters/{cluster_id} |
activationPolicy | string | Optional. Specifies whether an instance needs to spin up. Once the instance is active, the activation policy can be updated to the NEVER to stop the instance. Likewise, the activation policy can be updated to ALWAYS to start the instance. There are restrictions around when an instance can/cannot be activated (for example, a read pool instance should be stopped before stopping primary etc.). Please refer to the API documentation for more details. (ACTIVATION_POLICY_UNSPECIFIED, ALWAYS, NEVER) |
annotations | object | Annotations to allow client tools to store small amount of arbitrary data. This is distinct from labels. https://google.aip.dev/128 |
availabilityType | string | Availability type of an Instance. If empty, defaults to REGIONAL for primary instances. For read pools, availability_type is always UNSPECIFIED. Instances in the read pools are evenly distributed across available zones within the region (i.e. read pools with more than one node will have a node in at least two zones). (AVAILABILITY_TYPE_UNSPECIFIED, ZONAL, REGIONAL) |
clientConnectionConfig | object | Optional. Client connection specific configurations (id: ClientConnectionConfig) |
connectionPoolConfig | object | Optional. The configuration for Managed Connection Pool (MCP). (id: ConnectionPoolConfig) |
createTime | string (google-datetime) | Output only. Create time stamp |
dataApiAccess | string | Optional. Controls whether the Data API is enabled for this instance. When enabled, this allows authorized users to connect to the instance from the public internet using the executeSql API, even for private IP instances. If this is not specified, the data API is enabled by default for Google internal services like AlloyDB Studio. Disable it explicitly to disallow Google internal services as well. (DEFAULT_DATA_API_ENABLED_FOR_GOOGLE_CLOUD_SERVICES, DISABLED, ENABLED) |
databaseFlags | object | Database flags. Set at the instance level. They are copied from the primary instance on secondary instance creation. Flags that have restrictions default to the value at primary instance on read instances during creation. Read instances can set new flags or override existing flags that are relevant for reads, for example, for enabling columnar cache on a read instance. Flags set on read instance might or might not be present on the primary instance. This is a list of "key": "value" pairs. "key": The name of the flag. These flags are passed at instance setup time, so include both server options and system variables for Postgres. Flags are specified with underscores, not hyphens. "value": The value of the flag. Booleans are set to on for true and off for false. This field must be omitted if the flag doesn't take a value. |
deleteTime | string (google-datetime) | Output only. Delete time stamp |
displayName | string | User-settable and human-readable display name for the Instance. |
etag | string | For Resource freshness validation (https://google.aip.dev/154) |
gceZone | string | 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. |
instanceType | string | Required. The type of the instance. Specified at creation time. (INSTANCE_TYPE_UNSPECIFIED, PRIMARY, READ_POOL, SECONDARY) |
ipAddress | string | Output only. The IP address for the Instance. This is the connection endpoint for an end-user application. |
labels | object | Labels as key value pairs |
machineConfig | object | Configurations for the machines that host the underlying database engine. (id: MachineConfig) |
maintenanceVersionName | string | Output only. Maintenance version of the instance, for example: POSTGRES_15.2025_07_15.04_00. Output only. Update this field via the parent cluster's maintenance_version field(s). |
networkConfig | object | Optional. Instance-level network configuration. (id: InstanceNetworkConfig) |
nodes | array | Output only. List of available read-only VMs in this instance, including the standby for a PRIMARY instance. |
observabilityConfig | object | Configuration for observability. (id: ObservabilityInstanceConfig) |
outboundPublicIpAddresses | array | Output only. All outbound public IP addresses configured for the instance. |
pscInstanceConfig | object | Optional. The configuration for Private Service Connect (PSC) for the instance. (id: PscInstanceConfig) |
publicIpAddress | string | Output only. The public IP addresses for the Instance. This is available ONLY when enable_public_ip is set. This is the connection endpoint for an end-user application. |
queryInsightsConfig | object | Configuration for query insights. (id: QueryInsightsInstanceConfig) |
readPoolConfig | object | Read pool instance configuration. This is required if the value of instanceType is READ_POOL. (id: ReadPoolConfig) |
reconciling | boolean | Output only. Reconciling (https://google.aip.dev/128#reconciliation). 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. |
satisfiesPzs | boolean | Output only. Reserved for future use. |
state | string | Output only. The current serving state of the instance. (STATE_UNSPECIFIED, READY, STOPPED, CREATING, DELETING, MAINTENANCE, FAILED, BOOTSTRAPPING, PROMOTING, SWITCHOVER, STOPPING, STARTING) |
uid | string | Output only. The system-generated UID of the resource. The UID is assigned when the resource is created, and it is retained until it is deleted. |
updateTime | string (google-datetime) | Output only. Update time stamp |
writableNode | object | Details of a single node in the instance. Nodes in an AlloyDB instance are ephemeral, they can change during update, failover, autohealing and resize operations. (id: Node) |
| Name | Datatype | Description |
|---|
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | projectsId, locationsId, clustersId, instancesId | view | Gets details of a single Instance. |
list | select | projectsId, locationsId, clustersId | pageToken, pageSize, filter, orderBy | Lists Instances in a given project and location. |
create | insert | projectsId, locationsId, clustersId | requestId, validateOnly, instanceId | Creates a new Instance in a given project and location. |
patch | update | projectsId, locationsId, clustersId, instancesId | updateMask, allowMissing, requestId, validateOnly | Updates the parameters of a single Instance. |
delete | delete | projectsId, locationsId, clustersId, instancesId | requestId, etag, validateOnly | Deletes a single Instance. |
inject_fault | exec | projectsId, locationsId, clustersId, instancesId | Injects fault in an instance. Imperative only. | |
failover | exec | projectsId, locationsId, clustersId, instancesId | Forces a Failover for a highly available instance. Failover promotes the HA standby instance as the new primary. Imperative only. | |
restart | exec | projectsId, locationsId, clustersId, instancesId | Restart an Instance in a cluster. Imperative only. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
clustersId | string | |
instancesId | string | |
locationsId | string | |
projectsId | string | |
allowMissing | boolean | |
etag | string | |
filter | string | |
instanceId | string | |
orderBy | string | |
pageSize | integer (int32) | |
pageToken | string | |
requestId | string | |
updateMask | string (google-fieldmask) | |
validateOnly | boolean | |
view | string |
SELECT examples
- get
- list
Gets details of a single Instance.
SELECT
name,
activationPolicy,
annotations,
availabilityType,
clientConnectionConfig,
connectionPoolConfig,
createTime,
dataApiAccess,
databaseFlags,
deleteTime,
displayName,
etag,
gceZone,
instanceType,
ipAddress,
labels,
machineConfig,
maintenanceVersionName,
networkConfig,
nodes,
observabilityConfig,
outboundPublicIpAddresses,
pscInstanceConfig,
publicIpAddress,
queryInsightsConfig,
readPoolConfig,
reconciling,
satisfiesPzs,
state,
uid,
updateTime,
writableNode
FROM google.alloydb.instances
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND clustersId = '{{ clustersId }}' -- required
AND instancesId = '{{ instancesId }}' -- required
AND view = '{{ view }}'
;
Lists Instances in a given project and location.
SELECT
*
FROM google.alloydb.instances
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND clustersId = '{{ clustersId }}' -- required
AND pageToken = '{{ pageToken }}'
AND pageSize = '{{ pageSize }}'
AND filter = '{{ filter }}'
AND orderBy = '{{ orderBy }}'
;
INSERT examples
- create
- Manifest
Creates a new Instance in a given project and location.
INSERT INTO google.alloydb.instances (
data__observabilityConfig,
data__labels,
data__dataApiAccess,
data__gceZone,
data__etag,
data__availabilityType,
data__databaseFlags,
data__annotations,
data__pscInstanceConfig,
data__activationPolicy,
data__instanceType,
data__displayName,
data__machineConfig,
data__queryInsightsConfig,
data__readPoolConfig,
data__connectionPoolConfig,
data__clientConnectionConfig,
data__networkConfig,
projectsId,
locationsId,
clustersId,
requestId,
validateOnly,
instanceId
)
SELECT
'{{ observabilityConfig }}',
'{{ labels }}',
'{{ dataApiAccess }}',
'{{ gceZone }}',
'{{ etag }}',
'{{ availabilityType }}',
'{{ databaseFlags }}',
'{{ annotations }}',
'{{ pscInstanceConfig }}',
'{{ activationPolicy }}',
'{{ instanceType }}',
'{{ displayName }}',
'{{ machineConfig }}',
'{{ queryInsightsConfig }}',
'{{ readPoolConfig }}',
'{{ connectionPoolConfig }}',
'{{ clientConnectionConfig }}',
'{{ networkConfig }}',
'{{ projectsId }}',
'{{ locationsId }}',
'{{ clustersId }}',
'{{ requestId }}',
'{{ validateOnly }}',
'{{ instanceId }}'
RETURNING
name,
done,
error,
metadata,
response
;
# Description fields are for documentation purposes
- name: instances
props:
- name: projectsId
value: "{{ projectsId }}"
description: Required parameter for the instances resource.
- name: locationsId
value: "{{ locationsId }}"
description: Required parameter for the instances resource.
- name: clustersId
value: "{{ clustersId }}"
description: Required parameter for the instances resource.
- name: observabilityConfig
description: |
Configuration for observability.
value:
enabled: {{ enabled }}
trackActiveQueries: {{ trackActiveQueries }}
recordApplicationTags: {{ recordApplicationTags }}
trackWaitEvents: {{ trackWaitEvents }}
maxQueryStringLength: {{ maxQueryStringLength }}
preserveComments: {{ preserveComments }}
queryPlansPerMinute: {{ queryPlansPerMinute }}
trackWaitEventTypes: {{ trackWaitEventTypes }}
- name: labels
value: "{{ labels }}"
description: |
Labels as key value pairs
- name: dataApiAccess
value: "{{ dataApiAccess }}"
description: |
Optional. Controls whether the Data API is enabled for this instance. When enabled, this allows authorized users to connect to the instance from the public internet using the `executeSql` API, even for private IP instances. If this is not specified, the data API is enabled by default for Google internal services like AlloyDB Studio. Disable it explicitly to disallow Google internal services as well.
valid_values: ['DEFAULT_DATA_API_ENABLED_FOR_GOOGLE_CLOUD_SERVICES', 'DISABLED', 'ENABLED']
- name: gceZone
value: "{{ gceZone }}"
description: |
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.
- name: etag
value: "{{ etag }}"
description: |
For Resource freshness validation (https://google.aip.dev/154)
- name: availabilityType
value: "{{ availabilityType }}"
description: |
Availability type of an Instance. If empty, defaults to REGIONAL for primary instances. For read pools, availability_type is always UNSPECIFIED. Instances in the read pools are evenly distributed across available zones within the region (i.e. read pools with more than one node will have a node in at least two zones).
valid_values: ['AVAILABILITY_TYPE_UNSPECIFIED', 'ZONAL', 'REGIONAL']
- name: databaseFlags
value: "{{ databaseFlags }}"
description: |
Database flags. Set at the instance level. They are copied from the primary instance on secondary instance creation. Flags that have restrictions default to the value at primary instance on read instances during creation. Read instances can set new flags or override existing flags that are relevant for reads, for example, for enabling columnar cache on a read instance. Flags set on read instance might or might not be present on the primary instance. This is a list of "key": "value" pairs. "key": The name of the flag. These flags are passed at instance setup time, so include both server options and system variables for Postgres. Flags are specified with underscores, not hyphens. "value": The value of the flag. Booleans are set to **on** for true and **off** for false. This field must be omitted if the flag doesn't take a value.
- name: annotations
value: "{{ annotations }}"
description: |
Annotations to allow client tools to store small amount of arbitrary data. This is distinct from labels. https://google.aip.dev/128
- name: pscInstanceConfig
description: |
Optional. The configuration for Private Service Connect (PSC) for the instance.
value:
pscDnsName: "{{ pscDnsName }}"
pscInterfaceConfigs:
- networkAttachmentResource: "{{ networkAttachmentResource }}"
serviceAttachmentLink: "{{ serviceAttachmentLink }}"
pscAutoConnections:
- status: "{{ status }}"
ipAddress: "{{ ipAddress }}"
consumerProject: "{{ consumerProject }}"
consumerNetwork: "{{ consumerNetwork }}"
consumerNetworkStatus: "{{ consumerNetworkStatus }}"
allowedConsumerProjects:
- "{{ allowedConsumerProjects }}"
- name: activationPolicy
value: "{{ activationPolicy }}"
description: |
Optional. Specifies whether an instance needs to spin up. Once the instance is active, the activation policy can be updated to the `NEVER` to stop the instance. Likewise, the activation policy can be updated to `ALWAYS` to start the instance. There are restrictions around when an instance can/cannot be activated (for example, a read pool instance should be stopped before stopping primary etc.). Please refer to the API documentation for more details.
valid_values: ['ACTIVATION_POLICY_UNSPECIFIED', 'ALWAYS', 'NEVER']
- name: instanceType
value: "{{ instanceType }}"
description: |
Required. The type of the instance. Specified at creation time.
valid_values: ['INSTANCE_TYPE_UNSPECIFIED', 'PRIMARY', 'READ_POOL', 'SECONDARY']
- name: displayName
value: "{{ displayName }}"
description: |
User-settable and human-readable display name for the Instance.
- name: machineConfig
description: |
Configurations for the machines that host the underlying database engine.
value:
machineType: "{{ machineType }}"
cpuCount: {{ cpuCount }}
- name: queryInsightsConfig
description: |
Configuration for query insights.
value:
recordApplicationTags: {{ recordApplicationTags }}
queryStringLength: {{ queryStringLength }}
recordClientAddress: {{ recordClientAddress }}
queryPlansPerMinute: {{ queryPlansPerMinute }}
- name: readPoolConfig
description: |
Read pool instance configuration. This is required if the value of instanceType is READ_POOL.
value:
nodeCount: {{ nodeCount }}
- name: connectionPoolConfig
description: |
Optional. The configuration for Managed Connection Pool (MCP).
value:
flags: "{{ flags }}"
enabled: {{ enabled }}
authproxyPoolerCount: {{ authproxyPoolerCount }}
authproxyPoolerScalingType: "{{ authproxyPoolerScalingType }}"
poolerCount: {{ poolerCount }}
poolerScalingType: "{{ poolerScalingType }}"
- name: clientConnectionConfig
description: |
Optional. Client connection specific configurations
value:
requireConnectors: {{ requireConnectors }}
sslConfig:
sslMode: "{{ sslMode }}"
caSource: "{{ caSource }}"
- name: networkConfig
description: |
Optional. Instance-level network configuration.
value:
authorizedExternalNetworks:
- cidrRange: "{{ cidrRange }}"
enablePublicIp: {{ enablePublicIp }}
network: "{{ network }}"
allocatedIpRangeOverride: "{{ allocatedIpRangeOverride }}"
enableOutboundPublicIp: {{ enableOutboundPublicIp }}
- name: requestId
value: "{{ requestId }}"
- name: validateOnly
value: {{ validateOnly }}
- name: instanceId
value: "{{ instanceId }}"
UPDATE examples
- patch
Updates the parameters of a single Instance.
UPDATE google.alloydb.instances
SET
data__observabilityConfig = '{{ observabilityConfig }}',
data__labels = '{{ labels }}',
data__dataApiAccess = '{{ dataApiAccess }}',
data__gceZone = '{{ gceZone }}',
data__etag = '{{ etag }}',
data__availabilityType = '{{ availabilityType }}',
data__databaseFlags = '{{ databaseFlags }}',
data__annotations = '{{ annotations }}',
data__pscInstanceConfig = '{{ pscInstanceConfig }}',
data__activationPolicy = '{{ activationPolicy }}',
data__instanceType = '{{ instanceType }}',
data__displayName = '{{ displayName }}',
data__machineConfig = '{{ machineConfig }}',
data__queryInsightsConfig = '{{ queryInsightsConfig }}',
data__readPoolConfig = '{{ readPoolConfig }}',
data__connectionPoolConfig = '{{ connectionPoolConfig }}',
data__clientConnectionConfig = '{{ clientConnectionConfig }}',
data__networkConfig = '{{ networkConfig }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND clustersId = '{{ clustersId }}' --required
AND instancesId = '{{ instancesId }}' --required
AND updateMask = '{{ updateMask}}'
AND allowMissing = {{ allowMissing}}
AND requestId = '{{ requestId}}'
AND validateOnly = {{ validateOnly}}
RETURNING
name,
done,
error,
metadata,
response;
DELETE examples
- delete
Deletes a single Instance.
DELETE FROM google.alloydb.instances
WHERE projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND clustersId = '{{ clustersId }}' --required
AND instancesId = '{{ instancesId }}' --required
AND requestId = '{{ requestId }}'
AND etag = '{{ etag }}'
AND validateOnly = '{{ validateOnly }}'
;
Lifecycle Methods
- inject_fault
- failover
- restart
Injects fault in an instance. Imperative only.
EXEC google.alloydb.instances.inject_fault
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@clustersId='{{ clustersId }}' --required,
@instancesId='{{ instancesId }}' --required
@@json=
'{
"requestId": "{{ requestId }}",
"validateOnly": {{ validateOnly }},
"faultType": "{{ faultType }}"
}'
;
Forces a Failover for a highly available instance. Failover promotes the HA standby instance as the new primary. Imperative only.
EXEC google.alloydb.instances.failover
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@clustersId='{{ clustersId }}' --required,
@instancesId='{{ instancesId }}' --required
@@json=
'{
"requestId": "{{ requestId }}",
"validateOnly": {{ validateOnly }}
}'
;
Restart an Instance in a cluster. Imperative only.
EXEC google.alloydb.instances.restart
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@clustersId='{{ clustersId }}' --required,
@instancesId='{{ instancesId }}' --required
@@json=
'{
"nodeIds": "{{ nodeIds }}",
"requestId": "{{ requestId }}",
"validateOnly": {{ validateOnly }}
}'
;