github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/website/source/docs/providers/google/r/sql_database_instance.html.markdown (about) 1 --- 2 layout: "google" 3 page_title: "Google: google_sql_database_instance" 4 sidebar_current: "docs-google-sql-database-instance" 5 description: |- 6 Creates a new SQL database instance in Google Cloud SQL. 7 --- 8 9 # google\_sql\_database\_instance 10 11 Creates a new Google SQL Database Instance. For more information, see the [official documentation](https://cloud.google.com/sql/), or the [JSON API](https://cloud.google.com/sql/docs/admin-api/v1beta4/instances). 12 13 ~> **NOTE on `google_sql_database_instance`:** - Second-generation instances include a 14 default 'root'@'%' user with no password. This user will be deleted by Terraform on 15 instance creation. You should use a `google_sql_user` to define a customer user with 16 a restricted host and strong password. 17 18 19 ## Example Usage 20 21 Example creating a SQL Database. 22 23 ```hcl 24 resource "google_sql_database_instance" "master" { 25 name = "master-instance" 26 27 settings { 28 tier = "D0" 29 } 30 } 31 ``` 32 33 ## Argument Reference 34 35 The following arguments are supported: 36 37 * `region` - (Required) The region the instance will sit in. Note, this does 38 not line up with the Google Compute Engine (GCE) regions - your options are 39 `us-central`, `asia-west1`, `europe-west1`, and `us-east1`. 40 41 * `settings` - (Required) The settings to use for the database. The 42 configuration is detailed below. 43 44 - - - 45 46 * `database_version` - (Optional, Default: `MYSQL_5_6`) The MySQL version to 47 use. Can be either `MYSQL_5_6` or `MYSQL_5_7` for second-generation 48 instances, or `MYSQL_5_5` or `MYSQL_5_6` for first-generation instances. 49 See Google's [Second Generation Capabilities](https://cloud.google.com/sql/docs/1st-2nd-gen-differences) 50 for more information. 51 52 * `name` - (Optional, Computed) The name of the instance. If the name is left 53 blank, Terraform will randomly generate one when the instance is first 54 created. This is done because after a name is used, it cannot be reused for 55 up to [one week](https://cloud.google.com/sql/docs/delete-instance). 56 57 * `master_instance_name` - (Optional) The name of the instance that will act as 58 the master in the replication setup. Note, this requires the master to have 59 `binary_log_enabled` set, as well as existing backups. 60 61 * `project` - (Optional) The project in which the resource belongs. If it 62 is not provided, the provider project is used. 63 64 * `replica_configuration` - (Optional) The configuration for replication. The 65 configuration is detailed below. 66 67 The required `settings` block supports: 68 69 * `tier` - (Required) The machine tier (First Generation) or type (Second Generation) to use. See 70 [tiers](https://cloud.google.com/sql/docs/admin-api/v1beta4/tiers) for more details and 71 supported versions. 72 73 * `activation_policy` - (Optional) This specifies when the instance should be 74 active. Can be either `ALWAYS`, `NEVER` or `ON_DEMAND`. 75 76 * `authorized_gae_applications` - (Optional) A list of Google App Engine (GAE) 77 project names that are allowed to access this instance. 78 79 * `crash_safe_replication` - (Optional) Specific to read instances, indicates 80 when crash-safe replication flags are enabled. 81 82 * `disk_autoresize` - (Optional, Second Generation, Default: `false`) Configuration to increase storage size automatically. 83 84 * `disk_size` - (Optional, Second Generation, Default: `10`) The size of data disk, in GB. Size of a running instance cannot be reduced but can be increased. 85 86 * `disk_type` - (Optional, Second Generation, Default: `PD_SSD`) The type of data disk: PD_SSD or PD_HDD. 87 88 * `pricing_plan` - (Optional, First Generation) Pricing plan for this instance, can be one of 89 `PER_USE` or `PACKAGE`. 90 91 * `replication_type` - (Optional) Replication type for this instance, can be one 92 of `ASYNCHRONOUS` or `SYNCHRONOUS`. 93 94 The optional `settings.database_flags` sublist supports: 95 96 * `name` - (Optional) Name of the flag. 97 98 * `value` - (Optional) Value of the flag. 99 100 The optional `settings.backup_configuration` subblock supports: 101 102 * `binary_log_enabled` - (Optional) True iff binary logging is enabled. If 103 `logging` is false, this must be as well. 104 105 * `enabled` - (Optional) True iff backup configuration is enabled. 106 107 * `start_time` - (Optional) `HH:MM` format time indicating when backup 108 configuration starts. 109 110 The optional `settings.ip_configuration` subblock supports: 111 112 * `ipv4_enabled` - (Optional) True iff the instance should be assigned an IP 113 address. 114 115 * `require_ssl` - (Optional) True iff mysqld should default to `REQUIRE X509` 116 for users connecting over IP. 117 118 The optional `settings.ip_configuration.authorized_networks[]` sublist supports: 119 120 * `expiration_time` - (Optional) The [RFC 3339](https://tools.ietf.org/html/rfc3339) 121 formatted date time string indicating when this whitelist expires. 122 123 * `name` - (Optional) A name for this whitelist entry. 124 125 * `value` - (Optional) A CIDR notation IPv4 or IPv6 address that is allowed to 126 access this instance. Must be set even if other two attributes are not for 127 the whitelist to become active. 128 129 The optional `settings.location_preference` subblock supports: 130 131 * `follow_gae_application` - (Optional) A GAE application whose zone to remain 132 in. Must be in the same region as this instance. 133 134 * `zone` - (Optional) The preferred compute engine 135 [zone](https://cloud.google.com/compute/docs/zones?hl=en). 136 137 The optional `settings.maintenance_window` subblock for Second Generation 138 instances declares a one-hour [maintenance window](https://cloud.google.com/sql/docs/instance-settings?hl=en#maintenance-window-2ndgen) 139 when an Instance can automatically restart to apply updates. It supports: 140 141 * `day` - (Optional) Day of week (`1-7`), starting on Monday 142 143 * `hour` - (Optional) Hour of day (`0-23`), ignored if `day` not set 144 145 * `update_track` - (Optional) Receive updates earlier (`canary`) or later 146 (`stable`) 147 148 The optional `replica_configuration` block must have `master_instance_name` set 149 to work, cannot be updated, and supports: 150 151 * `ca_certificate` - (Optional) PEM representation of the trusted CA's x509 152 certificate. 153 154 * `client_certificate` - (Optional) PEM representation of the slave's x509 155 certificate. 156 157 * `client_key` - (Optional) PEM representation of the slave's private key. The 158 corresponding public key in encoded in the `client_certificate`. 159 160 * `connect_retry_interval` - (Optional, Default: 60) The number of seconds 161 between connect retries. 162 163 * `dump_file_path` - (Optional) Path to a SQL file in GCS from which slave 164 instances are created. Format is `gs://bucket/filename`. 165 166 * `master_heartbeat_period` - (Optional) Time in ms between replication 167 heartbeats. 168 169 * `password` - (Optional) Password for the replication connection. 170 171 * `sslCipher` - (Optional) Permissible ciphers for use in SSL encryption. 172 173 * `username` - (Optional) Username for replication connection. 174 175 * `verify_server_certificate` - (Optional) True iff the master's common name 176 value is checked during the SSL handshake. 177 178 ## Attributes Reference 179 180 In addition to the arguments listed above, the following computed attributes are 181 exported: 182 183 * `ip_address.0.ip_address` - The IPv4 address assigned. 184 185 * `ip_address.0.time_to_retire` - The time this IP address will be retired, in RFC 186 3339 format. 187 188 * `self_link` - The URI of the created resource. 189 190 * `settings.version` - Used to make sure changes to the `settings` block are 191 atomic.