Skip to main content

instances

Creates, updates, deletes, gets or lists an instances resource.

Overview

Nameinstances
TypeResource
Idgoogle.alloydb.instances

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringOutput 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}
activationPolicystringOptional. 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.
annotationsobjectAnnotations to allow client tools to store small amount of arbitrary data. This is distinct from labels. https://google.aip.dev/128
availabilityTypestringAvailability 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).
clientConnectionConfigobjectOptional. Client connection specific configurations (id: ClientConnectionConfig)
createTimestring (google-datetime)Output only. Create time stamp
databaseFlagsobjectDatabase 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.
deleteTimestring (google-datetime)Output only. Delete time stamp
displayNamestringUser-settable and human-readable display name for the Instance.
etagstringFor Resource freshness validation (https://google.aip.dev/154)
gceZonestringThe 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.
instanceTypestringRequired. The type of the instance. Specified at creation time.
ipAddressstringOutput only. The IP address for the Instance. This is the connection endpoint for an end-user application.
labelsobjectLabels as key value pairs
machineConfigobjectConfigurations for the machines that host the underlying database engine. (id: MachineConfig)
networkConfigobjectOptional. Instance-level network configuration. (id: InstanceNetworkConfig)
nodesarrayOutput only. List of available read-only VMs in this instance, including the standby for a PRIMARY instance.
observabilityConfigobjectConfiguration for observability. (id: ObservabilityInstanceConfig)
outboundPublicIpAddressesarrayOutput only. All outbound public IP addresses configured for the instance.
pscInstanceConfigobjectOptional. The configuration for Private Service Connect (PSC) for the instance. (id: PscInstanceConfig)
publicIpAddressstringOutput 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.
queryInsightsConfigobjectConfiguration for query insights. (id: QueryInsightsInstanceConfig)
readPoolConfigobjectRead pool instance configuration. This is required if the value of instanceType is READ_POOL. (id: ReadPoolConfig)
reconcilingbooleanOutput 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.
satisfiesPzsbooleanOutput only. Reserved for future use.
statestringOutput only. The current serving state of the instance.
uidstringOutput 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.
updateTimestring (google-datetime)Output only. Update time stamp
writableNodeobjectOutput only. This is set for the read-write VM of the PRIMARY instance only. (id: Node)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsId, locationsId, clustersId, instancesIdviewGets details of a single Instance.
listselectprojectsId, locationsId, clustersIdpageSize, pageToken, filter, orderByLists Instances in a given project and location.
createinsertprojectsId, locationsId, clustersIdinstanceId, requestId, validateOnlyCreates a new Instance in a given project and location.
patchupdateprojectsId, locationsId, clustersId, instancesIdupdateMask, requestId, validateOnly, allowMissingUpdates the parameters of a single Instance.
deletedeleteprojectsId, locationsId, clustersId, instancesIdrequestId, etag, validateOnlyDeletes a single Instance.
failoverexecprojectsId, locationsId, clustersId, instancesIdForces a Failover for a highly available instance. Failover promotes the HA standby instance as the new primary. Imperative only.
inject_faultexecprojectsId, locationsId, clustersId, instancesIdInjects fault in an instance. Imperative only.
restartexecprojectsId, locationsId, clustersId, instancesIdRestart 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.

NameDatatypeDescription
clustersIdstring
instancesIdstring
locationsIdstring
projectsIdstring
allowMissingboolean
etagstring
filterstring
instanceIdstring
orderBystring
pageSizeinteger (int32)
pageTokenstring
requestIdstring
updateMaskstring (google-fieldmask)
validateOnlyboolean
viewstring

SELECT examples

Gets details of a single Instance.

SELECT
name,
activationPolicy,
annotations,
availabilityType,
clientConnectionConfig,
createTime,
databaseFlags,
deleteTime,
displayName,
etag,
gceZone,
instanceType,
ipAddress,
labels,
machineConfig,
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 }}';

INSERT examples

Creates a new Instance in a given project and location.

INSERT INTO google.alloydb.instances (
data__displayName,
data__labels,
data__instanceType,
data__machineConfig,
data__availabilityType,
data__gceZone,
data__databaseFlags,
data__queryInsightsConfig,
data__observabilityConfig,
data__readPoolConfig,
data__etag,
data__annotations,
data__clientConnectionConfig,
data__pscInstanceConfig,
data__networkConfig,
data__activationPolicy,
projectsId,
locationsId,
clustersId,
instanceId,
requestId,
validateOnly
)
SELECT
'{{ displayName }}',
'{{ labels }}',
'{{ instanceType }}',
'{{ machineConfig }}',
'{{ availabilityType }}',
'{{ gceZone }}',
'{{ databaseFlags }}',
'{{ queryInsightsConfig }}',
'{{ observabilityConfig }}',
'{{ readPoolConfig }}',
'{{ etag }}',
'{{ annotations }}',
'{{ clientConnectionConfig }}',
'{{ pscInstanceConfig }}',
'{{ networkConfig }}',
'{{ activationPolicy }}',
'{{ projectsId }}',
'{{ locationsId }}',
'{{ clustersId }}',
'{{ instanceId }}',
'{{ requestId }}',
'{{ validateOnly }}'
RETURNING
name,
done,
error,
metadata,
response
;

UPDATE examples

Updates the parameters of a single Instance.

UPDATE google.alloydb.instances
SET
data__displayName = '{{ displayName }}',
data__labels = '{{ labels }}',
data__instanceType = '{{ instanceType }}',
data__machineConfig = '{{ machineConfig }}',
data__availabilityType = '{{ availabilityType }}',
data__gceZone = '{{ gceZone }}',
data__databaseFlags = '{{ databaseFlags }}',
data__queryInsightsConfig = '{{ queryInsightsConfig }}',
data__observabilityConfig = '{{ observabilityConfig }}',
data__readPoolConfig = '{{ readPoolConfig }}',
data__etag = '{{ etag }}',
data__annotations = '{{ annotations }}',
data__clientConnectionConfig = '{{ clientConnectionConfig }}',
data__pscInstanceConfig = '{{ pscInstanceConfig }}',
data__networkConfig = '{{ networkConfig }}',
data__activationPolicy = '{{ activationPolicy }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND clustersId = '{{ clustersId }}' --required
AND instancesId = '{{ instancesId }}' --required
AND updateMask = '{{ updateMask}}'
AND requestId = '{{ requestId}}'
AND validateOnly = {{ validateOnly}}
AND allowMissing = {{ allowMissing}}
RETURNING
name,
done,
error,
metadata,
response;

DELETE examples

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

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 }}
}';