Skip to main content

instances

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

Overview​

Nameinstances
TypeResource
Idgoogle.sqladmin.instances

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringName of the Cloud SQL instance. This does not include the project ID.
availableMaintenanceVersionsarrayOutput only. List all maintenance versions applicable on the instance
backendTypestringThe backend type. SECOND_GEN: Cloud SQL database instance. EXTERNAL: A database server that is not managed by Google. This property is read-only; use the tier property in the settings object to determine the database type. (SQL_BACKEND_TYPE_UNSPECIFIED, FIRST_GEN, SECOND_GEN, EXTERNAL)
connectionNamestringConnection name of the Cloud SQL instance used in connection strings.
createTimestring (google-datetime)Output only. The time when the instance was created in RFC 3339 format, for example 2012-11-15T16:19:00.094Z.
currentDiskSizestring (int64)The current disk usage of the instance in bytes. This property has been deprecated. Use the "cloudsql.googleapis.com/database/disk/bytes_used" metric in Cloud Monitoring API instead. Please see this announcement for details.
databaseCenterIntegrationEnabledbooleanOptional. If true, instance metadata is sent to the Database Center. If false, instance metadata is not sent to the Database Center.
databaseInstalledVersionstringOutput only. Stores the current database version running on the instance including minor version such as MYSQL_8_0_18.
databaseVersionstringThe database engine type and version. The databaseVersion field cannot be changed after instance creation. (SQL_DATABASE_VERSION_UNSPECIFIED, MYSQL_5_1, MYSQL_5_5, MYSQL_5_6, MYSQL_5_7, MYSQL_8_0, MYSQL_8_0_18, MYSQL_8_0_26, MYSQL_8_0_27, MYSQL_8_0_28, MYSQL_8_0_29, MYSQL_8_0_30, MYSQL_8_0_31, MYSQL_8_0_32, MYSQL_8_0_33, MYSQL_8_0_34, MYSQL_8_0_35, MYSQL_8_0_36, MYSQL_8_0_37, MYSQL_8_0_39, MYSQL_8_0_40, MYSQL_8_0_41, MYSQL_8_0_42, MYSQL_8_0_43, MYSQL_8_0_44, MYSQL_8_0_45, MYSQL_8_0_46, MYSQL_8_4, MYSQL_9_7, SQLSERVER_2017_STANDARD, SQLSERVER_2017_ENTERPRISE, SQLSERVER_2017_EXPRESS, SQLSERVER_2017_WEB, POSTGRES_9_6, POSTGRES_10, POSTGRES_11, POSTGRES_12, POSTGRES_13, POSTGRES_14, POSTGRES_15, POSTGRES_16, POSTGRES_17, POSTGRES_18, POSTGRES_19, POSTGRES_20, SQLSERVER_2019_STANDARD, SQLSERVER_2019_ENTERPRISE, SQLSERVER_2019_EXPRESS, SQLSERVER_2019_WEB, SQLSERVER_2022_STANDARD, SQLSERVER_2022_ENTERPRISE, SQLSERVER_2022_EXPRESS, SQLSERVER_2022_WEB, SQLSERVER_2025_STANDARD, SQLSERVER_2025_ENTERPRISE, SQLSERVER_2025_EXPRESS)
diskEncryptionConfigurationobjectDisk encryption configuration specific to an instance. (id: DiskEncryptionConfiguration)
diskEncryptionStatusobjectDisk encryption status specific to an instance. (id: DiskEncryptionStatus)
dnsNamestringOutput only. The dns name of the instance.
dnsNamesarrayOutput only. The list of DNS names used by this instance.
etagstringThis field is deprecated and will be removed from a future version of the API. Use the settings.settingsVersion field instead.
failoverReplicaobjectThe name and status of the failover replica.
gceZonestringThe Compute Engine zone that the instance is currently serving from. This value could be different from the zone that was specified when the instance was created if the instance has failed over to its secondary zone. WARNING: Changing this might restart the instance.
geminiConfigobjectGemini instance configuration. (id: GeminiInstanceConfig)
includeReplicasForMajorVersionUpgradebooleanInput only. Determines whether an in-place major version upgrade of replicas happens when an in-place major version upgrade of a primary instance is initiated.
instanceTypestringThe instance type. (SQL_INSTANCE_TYPE_UNSPECIFIED, CLOUD_SQL_INSTANCE, ON_PREMISES_INSTANCE, READ_REPLICA_INSTANCE, READ_POOL_INSTANCE)
ipAddressesarrayThe assigned IP addresses for the instance.
ipv6AddressstringThe IPv6 address assigned to the instance. (Deprecated) This property was applicable only to First Generation instances.
kindstringThis is always sql#instance.
maintenanceVersionstringThe current software version on the instance.
masterInstanceNamestringThe name of the instance which will act as primary in the replication setup.
maxDiskSizestring (int64)The maximum disk size of the instance in bytes.
nodeCountinteger (int32)The number of read pool nodes in a read pool.
nodesarrayOutput only. Entries containing information about each read pool node of the read pool.
onPremisesConfigurationobjectConfiguration specific to on-premises instances. (id: OnPremisesConfiguration)
outOfDiskReportobjectThis field represents the report generated by the proactive database wellness job for OutOfDisk issues. * Writers: * the proactive database wellness job for OOD. * Readers: * the proactive database wellness job (id: SqlOutOfDiskReport)
primaryDnsNamestringOutput only. DEPRECATED: please use write_endpoint instead.
projectstringThe project ID of the project containing the Cloud SQL instance. The Google apps domain is prefixed if applicable.
pscServiceAttachmentLinkstringOutput only. The link to service attachment of PSC instance.
regionstringThe geographical region of the Cloud SQL instance. It can be one of the regions where Cloud SQL operates: For example, asia-east1, europe-west1, and us-central1. The default value is us-central1.
replicaConfigurationobjectConfiguration specific to failover replicas and read replicas. (id: ReplicaConfiguration)
replicaNamesarrayThe replicas of the instance.
replicationClusterobjectOptional. A primary instance and disaster recovery (DR) replica pair. A DR replica is a cross-region replica that you designate for failover in the event that the primary instance experiences regional failure. Applicable to MySQL and PostgreSQL. (id: ReplicationCluster)
rootPasswordstringInitial root password. Use only on creation. You must set root passwords before you can connect to PostgreSQL instances.
satisfiesPzibooleanOutput only. This status indicates whether the instance satisfies PZI. The status is reserved for future use.
satisfiesPzsbooleanThis status indicates whether the instance satisfies PZS. The status is reserved for future use.
scheduledMaintenanceobjectThe start time of any upcoming scheduled maintenance for this instance. (id: SqlScheduledMaintenance)
secondaryGceZonestringThe Compute Engine zone that the failover instance is currently serving from for a regional instance. This value could be different from the zone that was specified when the instance was created if the instance has failed over to its secondary/failover zone.
selfLinkstringThe URI of this resource.
serverCaCertobjectSSL configuration. (id: SslCert)
serviceAccountEmailAddressstringThe service account email address assigned to the instance.\This property is read-only.
settingsobjectThe user settings. (id: Settings)
sqlNetworkArchitecturestring (SQL_NETWORK_ARCHITECTURE_UNSPECIFIED, NEW_NETWORK_ARCHITECTURE, OLD_NETWORK_ARCHITECTURE)
statestringThe current serving state of the Cloud SQL instance. (SQL_INSTANCE_STATE_UNSPECIFIED, RUNNABLE, SUSPENDED, PENDING_DELETE, PENDING_CREATE, MAINTENANCE, FAILED, ONLINE_MAINTENANCE, REPAIRING)
suspensionReasonarrayIf the instance state is SUSPENDED, the reason for the suspension.
switchTransactionLogsToCloudStorageEnabledbooleanInput only. Whether Cloud SQL is enabled to switch storing point-in-time recovery log files from a data disk to Cloud Storage.
tagsobjectOptional. Input only. Immutable. Tag keys and tag values that are bound to this instance. You must represent each item in the map as: "" : "". For example, a single resource can have the following tags: "123/environment": "production", "123/costCenter": "marketing", For more information on tag creation and management, see https://cloud.google.com/resource-manager/docs/tags/tags-overview.
upgradableDatabaseVersionsarrayOutput only. All database versions that are available for upgrade.
writeEndpointstringOutput only. The dns name of the primary instance in a replication group.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectproject, instanceRetrieves a resource containing information about a Cloud SQL instance.
listselectprojectfilter, maxResults, pageTokenLists instances under a given project.
insertinsertprojectCreates a new Cloud SQL instance.
patchupdateproject, instancereconcilePscNetworking, reconcilePscNetworkingForcePartially updates settings of a Cloud SQL instance by merging the request with the current configuration. This method supports patch semantics.
updatereplaceproject, instanceUpdates settings of a Cloud SQL instance. Using this operation might cause your instance to restart.
deletedeleteproject, instanceenableFinalBackup, finalBackupDescription, finalBackupExpiryTime, finalBackupTtlDaysDeletes a Cloud SQL instance.
acquire_ssrs_leaseexecproject, instanceAcquire a lease for the setup of SQL Server Reporting Services (SSRS).
cloneexecproject, instanceCreates a Cloud SQL instance as a clone of the source instance. Using this operation might cause your instance to restart.
demoteexecproject, instanceDemotes an existing standalone instance to be a Cloud SQL read replica for an external database server.
demote_masterexecproject, instanceDemotes the stand-alone instance to be a Cloud SQL read replica for an external database server.
execute_sqlexecproject, instanceExecute SQL statements.
exportexecproject, instanceExports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL dump or CSV file.
failoverexecproject, instanceInitiates a manual failover of a high availability (HA) primary instance to a standby instance, which becomes the primary instance. Users are then rerouted to the new primary. For more information, see the Overview of high availability page in the Cloud SQL documentation. If using Legacy HA (MySQL only), this causes the instance to failover to its failover replica instance.
importexecproject, instanceImports data into a Cloud SQL instance from a SQL dump or CSV file in Cloud Storage.
list_entra_id_certificatesexecproject, instanceLists all versions of EntraID certificates for the specified instance. There can be up to three sets of certificates listed: the certificate that is currently in use, a future that has been added but not yet used to sign a certificate, and a certificate that has been rotated out.
list_server_certificatesexecproject, instanceLists all versions of server certificates and certificate authorities (CAs) for the specified instance. There can be up to three sets of certs listed: the certificate that is currently in use, a future that has been added but not yet used to sign a certificate, and a certificate that has been rotated out. For instances not using Certificate Authority Service (CAS) server CA, use ListServerCas instead.
perform_disk_shrinkexecproject, instancePerform Disk Shrink on primary instance.
point_in_time_restoreexecprojectsIdPoint in time restore for an instance managed by Google Cloud Backup and Disaster Recovery.
pre_check_major_version_upgradeexecproject, instanceExecute MVU Pre-checks
promote_replicaexecproject, instancefailoverPromotes the read replica instance to be an independent Cloud SQL primary instance. Using this operation might cause your instance to restart.
reencryptexecproject, instanceReencrypt CMEK instance with latest key version.
release_ssrs_leaseexecproject, instanceRelease a lease for the setup of SQL Server Reporting Services (SSRS).
reschedule_maintenanceexecproject, instanceReschedules the maintenance on the given instance.
reset_replica_sizeexecproject, instanceReset Replica Size to primary instance disk size.
reset_ssl_configexecproject, instancemodeDeletes all client certificates and generates a new server SSL certificate for the instance.
restartexecproject, instanceRestarts a Cloud SQL instance.
restore_backupexecproject, instanceRestores a backup of a Cloud SQL instance. Using this operation might cause your instance to restart.
rotate_entra_id_certificateexecproject, instanceRotates the server certificate version to one previously added with the addEntraIdCertificate method.
rotate_server_caexecproject, instanceRotates the server certificate to one signed by the Certificate Authority (CA) version previously added with the addServerCA method. For instances that have enabled Certificate Authority Service (CAS) based server CA, use RotateServerCertificate to rotate the server certificate.
rotate_server_certificateexecproject, instanceRotates the server certificate version to one previously added with the addServerCertificate method. For instances not using Certificate Authority Service (CAS) server CA, use RotateServerCa instead.
start_external_syncexecproject, instanceStart External primary instance migration.
start_replicaexecproject, instanceStarts the replication in the read replica instance.
stop_replicaexecproject, instanceStops the replication in the read replica instance.
switchoverexecproject, instancedbTimeoutSwitches over from the primary instance to the DR replica instance.
truncate_logexecproject, instanceTruncate MySQL general and slow query log tables MySQL only.
verify_external_sync_settingsexecproject, instanceVerify External primary instance external sync settings.

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
instancestring
projectstring
projectsIdstring
dbTimeoutstring (google-duration)
enableFinalBackupboolean
failoverboolean
filterstring
finalBackupDescriptionstring
finalBackupExpiryTimestring (google-datetime)
finalBackupTtlDaysstring (int64)
maxResultsinteger (uint32)
modestring
pageTokenstring
reconcilePscNetworkingboolean
reconcilePscNetworkingForceboolean

SELECT examples​

Retrieves a resource containing information about a Cloud SQL instance.

SELECT
name,
availableMaintenanceVersions,
backendType,
connectionName,
createTime,
currentDiskSize,
databaseCenterIntegrationEnabled,
databaseInstalledVersion,
databaseVersion,
diskEncryptionConfiguration,
diskEncryptionStatus,
dnsName,
dnsNames,
etag,
failoverReplica,
gceZone,
geminiConfig,
includeReplicasForMajorVersionUpgrade,
instanceType,
ipAddresses,
ipv6Address,
kind,
maintenanceVersion,
masterInstanceName,
maxDiskSize,
nodeCount,
nodes,
onPremisesConfiguration,
outOfDiskReport,
primaryDnsName,
project,
pscServiceAttachmentLink,
region,
replicaConfiguration,
replicaNames,
replicationCluster,
rootPassword,
satisfiesPzi,
satisfiesPzs,
scheduledMaintenance,
secondaryGceZone,
selfLink,
serverCaCert,
serviceAccountEmailAddress,
settings,
sqlNetworkArchitecture,
state,
suspensionReason,
switchTransactionLogsToCloudStorageEnabled,
tags,
upgradableDatabaseVersions,
writeEndpoint
FROM google.sqladmin.instances
WHERE project = '{{ project }}' -- required
AND instance = '{{ instance }}' -- required
;

INSERT examples​

Creates a new Cloud SQL instance.

INSERT INTO google.sqladmin.instances (
data__backendType,
data__connectionName,
data__currentDiskSize,
data__databaseCenterIntegrationEnabled,
data__databaseVersion,
data__diskEncryptionConfiguration,
data__diskEncryptionStatus,
data__etag,
data__failoverReplica,
data__gceZone,
data__geminiConfig,
data__includeReplicasForMajorVersionUpgrade,
data__instanceType,
data__ipAddresses,
data__ipv6Address,
data__kind,
data__maintenanceVersion,
data__masterInstanceName,
data__maxDiskSize,
data__name,
data__nodeCount,
data__onPremisesConfiguration,
data__outOfDiskReport,
data__project,
data__region,
data__replicaConfiguration,
data__replicaNames,
data__replicationCluster,
data__rootPassword,
data__satisfiesPzs,
data__scheduledMaintenance,
data__secondaryGceZone,
data__selfLink,
data__serverCaCert,
data__serviceAccountEmailAddress,
data__settings,
data__sqlNetworkArchitecture,
data__state,
data__suspensionReason,
data__switchTransactionLogsToCloudStorageEnabled,
data__tags,
project
)
SELECT
'{{ backendType }}',
'{{ connectionName }}',
'{{ currentDiskSize }}',
{{ databaseCenterIntegrationEnabled }},
'{{ databaseVersion }}',
'{{ diskEncryptionConfiguration }}',
'{{ diskEncryptionStatus }}',
'{{ etag }}',
'{{ failoverReplica }}',
'{{ gceZone }}',
'{{ geminiConfig }}',
{{ includeReplicasForMajorVersionUpgrade }},
'{{ instanceType }}',
'{{ ipAddresses }}',
'{{ ipv6Address }}',
'{{ kind }}',
'{{ maintenanceVersion }}',
'{{ masterInstanceName }}',
'{{ maxDiskSize }}',
'{{ name }}',
{{ nodeCount }},
'{{ onPremisesConfiguration }}',
'{{ outOfDiskReport }}',
'{{ project }}',
'{{ region }}',
'{{ replicaConfiguration }}',
'{{ replicaNames }}',
'{{ replicationCluster }}',
'{{ rootPassword }}',
{{ satisfiesPzs }},
'{{ scheduledMaintenance }}',
'{{ secondaryGceZone }}',
'{{ selfLink }}',
'{{ serverCaCert }}',
'{{ serviceAccountEmailAddress }}',
'{{ settings }}',
'{{ sqlNetworkArchitecture }}',
'{{ state }}',
'{{ suspensionReason }}',
{{ switchTransactionLogsToCloudStorageEnabled }},
'{{ tags }}',
'{{ project }}'
RETURNING
name,
acquireSsrsLeaseContext,
apiWarning,
backupContext,
endTime,
error,
exportContext,
importContext,
insertTime,
kind,
operationType,
preCheckMajorVersionUpgradeContext,
selfLink,
startTime,
status,
subOperationType,
targetId,
targetLink,
targetProject,
user
;

UPDATE examples​

Partially updates settings of a Cloud SQL instance by merging the request with the current configuration. This method supports patch semantics.

UPDATE google.sqladmin.instances
SET
data__backendType = '{{ backendType }}',
data__connectionName = '{{ connectionName }}',
data__currentDiskSize = '{{ currentDiskSize }}',
data__databaseCenterIntegrationEnabled = {{ databaseCenterIntegrationEnabled }},
data__databaseVersion = '{{ databaseVersion }}',
data__diskEncryptionConfiguration = '{{ diskEncryptionConfiguration }}',
data__diskEncryptionStatus = '{{ diskEncryptionStatus }}',
data__etag = '{{ etag }}',
data__failoverReplica = '{{ failoverReplica }}',
data__gceZone = '{{ gceZone }}',
data__geminiConfig = '{{ geminiConfig }}',
data__includeReplicasForMajorVersionUpgrade = {{ includeReplicasForMajorVersionUpgrade }},
data__instanceType = '{{ instanceType }}',
data__ipAddresses = '{{ ipAddresses }}',
data__ipv6Address = '{{ ipv6Address }}',
data__kind = '{{ kind }}',
data__maintenanceVersion = '{{ maintenanceVersion }}',
data__masterInstanceName = '{{ masterInstanceName }}',
data__maxDiskSize = '{{ maxDiskSize }}',
data__name = '{{ name }}',
data__nodeCount = {{ nodeCount }},
data__onPremisesConfiguration = '{{ onPremisesConfiguration }}',
data__outOfDiskReport = '{{ outOfDiskReport }}',
data__project = '{{ project }}',
data__region = '{{ region }}',
data__replicaConfiguration = '{{ replicaConfiguration }}',
data__replicaNames = '{{ replicaNames }}',
data__replicationCluster = '{{ replicationCluster }}',
data__rootPassword = '{{ rootPassword }}',
data__satisfiesPzs = {{ satisfiesPzs }},
data__scheduledMaintenance = '{{ scheduledMaintenance }}',
data__secondaryGceZone = '{{ secondaryGceZone }}',
data__selfLink = '{{ selfLink }}',
data__serverCaCert = '{{ serverCaCert }}',
data__serviceAccountEmailAddress = '{{ serviceAccountEmailAddress }}',
data__settings = '{{ settings }}',
data__sqlNetworkArchitecture = '{{ sqlNetworkArchitecture }}',
data__state = '{{ state }}',
data__suspensionReason = '{{ suspensionReason }}',
data__switchTransactionLogsToCloudStorageEnabled = {{ switchTransactionLogsToCloudStorageEnabled }},
data__tags = '{{ tags }}'
WHERE
project = '{{ project }}' --required
AND instance = '{{ instance }}' --required
AND reconcilePscNetworking = {{ reconcilePscNetworking}}
AND reconcilePscNetworkingForce = {{ reconcilePscNetworkingForce}}
RETURNING
name,
acquireSsrsLeaseContext,
apiWarning,
backupContext,
endTime,
error,
exportContext,
importContext,
insertTime,
kind,
operationType,
preCheckMajorVersionUpgradeContext,
selfLink,
startTime,
status,
subOperationType,
targetId,
targetLink,
targetProject,
user;

REPLACE examples​

Updates settings of a Cloud SQL instance. Using this operation might cause your instance to restart.

REPLACE google.sqladmin.instances
SET
data__backendType = '{{ backendType }}',
data__connectionName = '{{ connectionName }}',
data__currentDiskSize = '{{ currentDiskSize }}',
data__databaseCenterIntegrationEnabled = {{ databaseCenterIntegrationEnabled }},
data__databaseVersion = '{{ databaseVersion }}',
data__diskEncryptionConfiguration = '{{ diskEncryptionConfiguration }}',
data__diskEncryptionStatus = '{{ diskEncryptionStatus }}',
data__etag = '{{ etag }}',
data__failoverReplica = '{{ failoverReplica }}',
data__gceZone = '{{ gceZone }}',
data__geminiConfig = '{{ geminiConfig }}',
data__includeReplicasForMajorVersionUpgrade = {{ includeReplicasForMajorVersionUpgrade }},
data__instanceType = '{{ instanceType }}',
data__ipAddresses = '{{ ipAddresses }}',
data__ipv6Address = '{{ ipv6Address }}',
data__kind = '{{ kind }}',
data__maintenanceVersion = '{{ maintenanceVersion }}',
data__masterInstanceName = '{{ masterInstanceName }}',
data__maxDiskSize = '{{ maxDiskSize }}',
data__name = '{{ name }}',
data__nodeCount = {{ nodeCount }},
data__onPremisesConfiguration = '{{ onPremisesConfiguration }}',
data__outOfDiskReport = '{{ outOfDiskReport }}',
data__project = '{{ project }}',
data__region = '{{ region }}',
data__replicaConfiguration = '{{ replicaConfiguration }}',
data__replicaNames = '{{ replicaNames }}',
data__replicationCluster = '{{ replicationCluster }}',
data__rootPassword = '{{ rootPassword }}',
data__satisfiesPzs = {{ satisfiesPzs }},
data__scheduledMaintenance = '{{ scheduledMaintenance }}',
data__secondaryGceZone = '{{ secondaryGceZone }}',
data__selfLink = '{{ selfLink }}',
data__serverCaCert = '{{ serverCaCert }}',
data__serviceAccountEmailAddress = '{{ serviceAccountEmailAddress }}',
data__settings = '{{ settings }}',
data__sqlNetworkArchitecture = '{{ sqlNetworkArchitecture }}',
data__state = '{{ state }}',
data__suspensionReason = '{{ suspensionReason }}',
data__switchTransactionLogsToCloudStorageEnabled = {{ switchTransactionLogsToCloudStorageEnabled }},
data__tags = '{{ tags }}'
WHERE
project = '{{ project }}' --required
AND instance = '{{ instance }}' --required
RETURNING
name,
acquireSsrsLeaseContext,
apiWarning,
backupContext,
endTime,
error,
exportContext,
importContext,
insertTime,
kind,
operationType,
preCheckMajorVersionUpgradeContext,
selfLink,
startTime,
status,
subOperationType,
targetId,
targetLink,
targetProject,
user;

DELETE examples​

Deletes a Cloud SQL instance.

DELETE FROM google.sqladmin.instances
WHERE project = '{{ project }}' --required
AND instance = '{{ instance }}' --required
AND enableFinalBackup = '{{ enableFinalBackup }}'
AND finalBackupDescription = '{{ finalBackupDescription }}'
AND finalBackupExpiryTime = '{{ finalBackupExpiryTime }}'
AND finalBackupTtlDays = '{{ finalBackupTtlDays }}'
;

Lifecycle Methods​

Acquire a lease for the setup of SQL Server Reporting Services (SSRS).

EXEC google.sqladmin.instances.acquire_ssrs_lease
@project='{{ project }}' --required,
@instance='{{ instance }}' --required
@@json=
'{
"acquireSsrsLeaseContext": "{{ acquireSsrsLeaseContext }}"
}'
;