terraform-provider-google/website/docs/r/sql_database.html.markdown
Stefan Schmidt 9e5aa27677 Add charset and collation to google_sql_database. (#183)
* Add charset and collation to google_sql_database.

* Add documentation for charset, collation attributes.

* Extend the existing acceptance test to also cover charset and collation.

* Charset and collation always have a value present. Also inline.

* Move charset and collation to optional arguments.

* Add charset and collection to the example.

* Document charset and collation defaults.

* Keep TestAccGoogleSqlDatabase_basic as is, add TestAccGoogleSqlDatabase_update.
2017-07-17 08:32:29 -07:00

1.6 KiB

layout page_title sidebar_current description
google Google: google_sql_database docs-google-sql-database Creates a new SQL database in Google Cloud SQL.

google_sql_database

Creates a new Google SQL Database on a Google SQL Database Instance. For more information, see the official documentation, or the JSON API.

Example Usage

Example creating a SQL Database.

resource "google_sql_database_instance" "master" {
  name = "master-instance"

  settings {
    tier = "D0"
  }
}

resource "google_sql_database" "users" {
  name      = "users-db"
  instance  = "${google_sql_database_instance.master.name}"
  charset   = "latin1"
  collation = "latin1_swedish_ci"
}

Argument Reference

The following arguments are supported:

  • name - (Required) The name of the database.

  • instance - (Required) The name of containing instance.


  • project - (Optional) The project in which the resource belongs. If it is not provided, the provider project is used.

  • charset - (Optional) The MySQL charset value (default "utf8").

  • collation - (Optional) The MySQL collation value (default "utf8_general_ci").

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • self_link - The URI of the created resource.

Import

SQL databases can be imported using the instance and name, e.g.

$ terraform import google_sql_database.database master-instance:users-db