Instances

Represents a Cloud SQL instance. Cloud SQL instances are SQL databases hosted in Google's cloud. The Instances resource provides methods for common configuration and management tasks. For more information, see Creating Instances and Instance Settings.

For a list of methods for this resource, see the end of this page.

Resource representations

An Instance resource.

{
  "kind": "sql#instance",
  "selfLink": string,
  "name": string,
  "connectionName": string,
  "etag": etag,
  "project": string,
  "state": string,
  "backendType": string,
  "databaseVersion": string,
  "region": string,
  "currentDiskSize": long,
  "maxDiskSize": long,
  "settings": {
    "kind": "sql#settings",
    "settingsVersion": long,
    "authorizedGaeApplications": [
      string
    ],
    "tier": string,
    "backupConfiguration": {
      "kind": "sql#backupConfiguration",
      "startTime": string,
      "enabled": boolean,
      "binaryLogEnabled": boolean
    },
    "pricingPlan": string,
    "replicationType": string,
    "activationPolicy": string,
    "ipConfiguration": {
      "ipv4Enabled": boolean,
      "authorizedNetworks": [
        {
          "kind": "sql#aclEntry",
          "value": string,
          "name": string,
          "expirationTime": datetime
        }
      ],
      "requireSsl": boolean
    },
    "locationPreference": {
      "kind": "sql#locationPreference",
      "followGaeApplication": string,
      "zone": string
    },
    "databaseFlags": [
      {
        "name": string,
        "value": string
      }
    ],
    "databaseReplicationEnabled": boolean,
    "crashSafeReplicationEnabled": boolean,
    "dataDiskSizeGb": long,
    "dataDiskType": string,
    "maintenanceWindow": {
      "kind": "sql#maintenanceWindow",
      "hour": integer,
      "day": integer,
      "updateTrack": string
    },
    "storageAutoResize": boolean,
    "storageAutoResizeLimit": long,
    "availabilityType": string,
    "userLabels": {
      (key): string
    }
  },
  "serverCaCert": sslCerts Resource,
  "ipAddresses": [
    {
      "ipAddress": string,
      "timeToRetire": datetime,
      "type": string
    }
  ],
  "instanceType": string,
  "masterInstanceName": string,
  "replicaNames": [
    string
  ],
  "failoverReplica": {
    "name": string,
    "available": boolean
  },
  "ipv6Address": string,
  "serviceAccountEmailAddress": string,
  "onPremisesConfiguration": {
    "kind": "sql#onPremisesConfiguration",
    "hostPort": string
  },
  "replicaConfiguration": {
    "kind": "sql#replicaConfiguration",
    "mysqlReplicaConfiguration": {
      "kind": "sql#mysqlReplicaConfiguration",
      "dumpFilePath": string,
      "username": string,
      "password": string,
      "connectRetryInterval": integer,
      "masterHeartbeatPeriod": long,
      "caCertificate": string,
      "clientCertificate": string,
      "clientKey": string,
      "sslCipher": string,
      "verifyServerCertificate": boolean
    },
    "failoverTarget": boolean
  },
  "suspensionReason": [
    string
  ],
  "gceZone": string
}
Property name Value Description Notes
backendType string
FIRST_GEN: First Generation instance. MySQL only.
SECOND_GEN: Second Generation instance or PostgreSQL instance.
EXTERNAL: A database server that is not managed by Google.
connectionName string Connection name of the Cloud SQL instance used in connection strings.
currentDiskSize long The current disk usage of the instance in bytes. This property has been deprecated. Users should use the "cloudsql.googleapis.com/database/disk/bytes_used" metric in Cloud Monitoring API instead. Please see https://groups.google.com/d/msg/google-cloud-sql-announce/I_7-F9EBhT0/BtvFtdFeAgAJ for details.
databaseVersion string The database engine type and version. The databaseVersion field can not be changed after instance creation. MySQL Second Generation instances: MYSQL_5_7 (default) or MYSQL_5_6. PostgreSQL instances: POSTGRES_9_6 MySQL First Generation instances: MYSQL_5_6 (default) or MYSQL_5_5 writable
etag etag HTTP 1.1 Entity tag for the resource.
failoverReplica object The name and status of the failover replica. This property is applicable only to Second Generation instances. writable
failoverReplica.available boolean The availability status of the failover replica. A false status indicates that the failover replica is out of sync. The master can only failover to the falover replica when the status is true.
failoverReplica.name string The name of the failover replica. If specified at instance creation, a failover replica is created for the instance. The name doesn't include the project ID. This property is applicable only to Second Generation instances. writable
gceZone string The 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.
instanceType string The instance type. This can be one of the following.
CLOUD_SQL_INSTANCE: A Cloud SQL instance that is not replicating from a master.
ON_PREMISES_INSTANCE: An instance running on the customer's premises.
READ_REPLICA_INSTANCE: A Cloud SQL instance configured as a read-replica.
ipAddresses[] list The assigned IP addresses for the instance.
ipAddresses[].ipAddress string The IP address assigned.
ipAddresses[].timeToRetire datetime The due time for this IP to be retired in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. This field is only available when the IP is scheduled to be retired.
ipAddresses[].type string The type of this IP address. A PRIMARY address is an address that can accept incoming connections. An OUTGOING address is the source address of connections originating from the instance, if supported.
ipv6Address string The IPv6 address assigned to the instance. This property is applicable only to First Generation instances.
kind string This is always sql#instance.
masterInstanceName string The name of the instance which will act as master in the replication setup. writable
maxDiskSize long The maximum disk size of the instance in bytes.
name string Name of the Cloud SQL instance. This does not include the project ID.
onPremisesConfiguration nested object Configuration specific to on-premises instances. writable
onPremisesConfiguration.hostPort string The host and port of the on-premises instance in host:port format
onPremisesConfiguration.kind string This is always sql#onPremisesConfiguration.
project string The project ID of the project containing the Cloud SQL instance. The Google apps domain is prefixed if applicable.
region string The geographical region. Defaults to us-central or us-central1 depending on the instance type (First Generation or Second Generation/PostgreSQL). For a complete list of valid values, see Instance Locations. The region cannot be changed after instance creation. writable
replicaConfiguration nested object Configuration specific to failover replicas and read replicas. writable
replicaConfiguration.failoverTarget boolean Specifies if the replica is the failover target. If the field is set to true the replica will be designated as a failover replica. In case the master instance fails, the replica instance will be promoted as the new master instance.

Only one replica can be specified as failover target, and the replica has to be in different zone with the master instance.

writable
replicaConfiguration.kind string This is always sql#replicaConfiguration.
replicaConfiguration.mysqlReplicaConfiguration nested object MySQL specific configuration when replicating from a MySQL on-premises master. Replication configuration information such as the username, password, certificates, and keys are not stored in the instance metadata. The configuration information is used only to set up the replication connection and is stored by MySQL in a file named master.info in the data directory. writable
replicaConfiguration.mysqlReplicaConfiguration.caCertificate string PEM representation of the trusted CA's x509 certificate. writable
replicaConfiguration.mysqlReplicaConfiguration.clientCertificate string PEM representation of the slave's x509 certificate. writable
replicaConfiguration.mysqlReplicaConfiguration.clientKey string PEM representation of the slave's private key. The corresponsing public key is encoded in the client's certificate. writable
replicaConfiguration.mysqlReplicaConfiguration.connectRetryInterval integer Seconds to wait between connect retries. MySQL's default is 60 seconds. writable
replicaConfiguration.mysqlReplicaConfiguration.dumpFilePath string Path to a SQL dump file in Google Cloud Storage from which the slave instance is to be created. The URI is in the form gs://bucketName/fileName. Compressed gzip files (.gz) are also supported. Dumps should have the binlog co-ordinates from which replication should begin. This can be accomplished by setting --master-data to 1 when using mysqldump. writable
replicaConfiguration.mysqlReplicaConfiguration.kind string This is always sql#mysqlReplicaConfiguration.
replicaConfiguration.mysqlReplicaConfiguration.masterHeartbeatPeriod long Interval in milliseconds between replication heartbeats. writable
replicaConfiguration.mysqlReplicaConfiguration.password string The password for the replication connection. writable
replicaConfiguration.mysqlReplicaConfiguration.sslCipher string A list of permissible ciphers to use for SSL encryption. writable
replicaConfiguration.mysqlReplicaConfiguration.username string The username for the replication connection. writable
replicaConfiguration.mysqlReplicaConfiguration.verifyServerCertificate boolean Whether or not to check the master's Common Name value in the certificate that it sends during the SSL handshake. writable
replicaNames[] list The replicas of the instance.
serverCaCert nested object SSL configuration.
serviceAccountEmailAddress string The service account email address assigned to the instance. This property is applicable only to Second Generation instances.
settings nested object The user settings.
settings.activationPolicy string The activation policy specifies when the instance is activated; it is applicable only when the instance state is RUNNABLE. Valid values:
ALWAYS: The instance is in a functioning state. The activation policy determines whether the instance responds to connection requests or not.
NEVER: The instance is off; it is not activated, even if a connection request arrives.
ON_DEMAND: The instance responds to incoming requests, and turns itself off when not in use. Instances with PER_USE pricing turn off after 15 minutes of inactivity. Instances with PER_PACKAGE pricing turn off after 12 hours of inactivity.
writable
settings.authorizedGaeApplications[] list The App Engine app IDs that can access this instance. This property is only applicable to First Generation instances. writable
settings.availabilityType string Availability type (PostgreSQL instances only). Potential values:
ZONAL: The instance serves data from only one zone. Outages in that zone affect data accessibility.
REGIONAL: The instance can serve data from more than one zone in a region (it is highly available).
For more information, see Overview of the High Availability Configuration.
settings.backupConfiguration nested object The daily backup configuration for the instance. writable
settings.backupConfiguration.binaryLogEnabled boolean Whether binary log is enabled. If backup configuration is disabled, binary log must be disabled as well. writable
settings.backupConfiguration.enabled boolean Whether this configuration is enabled. writable
settings.backupConfiguration.kind string This is always sql#backupConfiguration.
settings.backupConfiguration.startTime string Start time for the daily backup configuration in UTC timezone in the 24 hour format - HH:MM. writable
settings.crashSafeReplicationEnabled boolean Configuration specific to read replica instances. Indicates whether database flags for crash-safe replication are enabled. This property is only applicable to First Generation instances. writable
settings.dataDiskSizeGb long The size of data disk, in GB. The data disk size minimum is 10GB. Applies only to Second Generation instances. writable
settings.dataDiskType string The type of data disk: PD_SSD (default) or PD_HDD. Applies only to Second Generation instances. writable
settings.databaseFlags[] list The database flags passed to the instance at startup. writable
settings.databaseFlags[].name string The name of the flag. These flags are passed at instance startup. Flags should be specified with underscores, not hyphens. For more information, see Configuring Cloud SQL Flags in the Cloud SQL documentation, as well as the official MySQL documentation for server options and system variables, or the PostgreSQL documentation for server configuration.
settings.databaseFlags[].value string The value of the flag. Booleans should be set to on for true and off for false. This field must be omitted if the flag doesn't take a value.
settings.databaseReplicationEnabled boolean Configuration specific to read replica instances. Indicates whether replication is enabled or not. writable
settings.ipConfiguration nested object The settings for IP Management. This allows to enable or disable the instance IP and manage which external networks can connect to the instance. The IPv4 address cannot be disabled for Second Generation instances. writable
settings.ipConfiguration.authorizedNetworks[] list The list of external networks that are allowed to connect to the instance using the IP. In CIDR notation, also known as 'slash' notation (e.g. 192.168.100.0/24). writable
settings.ipConfiguration.authorizedNetworks[].expirationTime datetime The time when this access control entry expires in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. writable
settings.ipConfiguration.authorizedNetworks[].kind string This is always sql#aclEntry.
settings.ipConfiguration.authorizedNetworks[].name string An optional label to identify this entry. writable
settings.ipConfiguration.authorizedNetworks[].value string The whitelisted value for the access control list. For example, to grant access to a client from an external IP (IPv4 or IPv6) address or subnet, use that address or subnet here. writable
settings.ipConfiguration.ipv4Enabled boolean Whether the instance should be assigned an IP address or not. writable
settings.ipConfiguration.requireSsl boolean Whether SSL connections over IP should be enforced or not. writable
settings.kind string This is always sql#settings.
settings.locationPreference nested object The location preference settings. This allows the instance to be located as near as possible to either an App Engine app or Compute Engine zone for better performance. App Engine co-location is only applicable to First Generation instances. writable
settings.locationPreference.followGaeApplication string The App Engine application to follow, it must be in the same region as the Cloud SQL instance. writable
settings.locationPreference.kind string This is always sql#locationPreference.
settings.locationPreference.zone string The preferred Compute Engine zone (e.g. us-centra1-a, us-central1-b, etc.). writable
settings.maintenanceWindow nested object The maintenance window for this instance. This specifies when the instance may be restarted for maintenance purposes. Applies only to Second Generation instances. writable
settings.maintenanceWindow.day integer day of week (1-7), starting on Monday. writable
settings.maintenanceWindow.hour integer hour of day - 0 to 23. writable
settings.maintenanceWindow.kind string This is always sql#maintenanceWindow.
settings.maintenanceWindow.updateTrack string
settings.pricingPlan string The pricing plan for this instance. This can be either PER_USE or PACKAGE. Only PER_USE is supported for Second Generation instances. writable
settings.replicationType string The type of replication this instance uses. This can be either ASYNCHRONOUS or SYNCHRONOUS. writable
settings.settingsVersion long The version of instance settings. This is a required field for update method to make sure concurrent updates are handled properly. During update, use the most recent settingsVersion value for this instance and do not try to update this value.
settings.storageAutoResize boolean Configuration to increase storage size automatically. The default value is true. Applies only to Second Generation instances. writable
settings.storageAutoResizeLimit long The maximum size to which storage capacity can be automatically increased. The default value is 0, which specifies that there is no limit. Applies only to Second Generation instances. writable
settings.tier string The tier or machine type for this instance, for example db-n1-standard-1. For MySQL instances, this field determines whether the instance is Second Generation (recommended) or First Generation. For more information, see pricing. writable
settings.userLabels object User-provided labels, represented as a dictionary where each label is a single key value pair. writable
settings.userLabels.(key) string An individual label entry, composed of a key and a value. writable
state string The current serving state of the Cloud SQL instance. This can be one of the following.
RUNNABLE: The instance is running, or is ready to run when accessed.
SUSPENDED: The instance is not available, for example due to problems with billing.
PENDING_CREATE: The instance is being created.
MAINTENANCE: The instance is down for maintenance.
FAILED: The instance creation failed.
UNKNOWN_STATE: The state of the instance is unknown.
suspensionReason[] list If the instance state is SUSPENDED, the reason for the suspension. Potential values: BILLING_ISSUE, INTERNAL_MAINTENANCE, and OPERATIONAL_ISSUE.

Methods

clone
Creates a Cloud SQL instance as a clone of the source instance.
delete
Deletes a Cloud SQL instance.
demoteMaster
Reserved for future use.
export
Exports data from a Cloud SQL instance to a Google Cloud Storage bucket as a MySQL dump or CSV file.
failover
Failover the instance to its failover replica instance.
get
Retrieves a resource containing information about a Cloud SQL instance.
import
Imports data into a Cloud SQL instance from a MySQL dump or CSV file in a Google Cloud Storage bucket.
insert
Creates a new Cloud SQL instance.
list
Lists instances under a given project in alphabetical order by instance name.
patch
Updates settings of a Cloud SQL instance using patch semantics.
promoteReplica
Promotes the read replica instance to be a stand-alone Cloud SQL instance.
resetSslConfig
Deletes all client certificates and generates a new server SSL certificate for the instance.
restart
Restarts a Cloud SQL instance.
restoreBackup
Restores a backup of a Cloud SQL instance.
startReplica
Starts the replication in the read replica instance.
stopReplica
Stops the replication in the read replica instance.
truncateLog
Truncate MySQL general and slow query log tables
update
Updates settings of a Cloud SQL instance.

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Cloud SQL for PostgreSQL