terraform-provider-google/website/docs/r/sql_database.html.markdown
Stefan Schmidt caeb43e39a Mark google_sql_database.{charset,collation} as computed instead of having defaults (#229)
* Mark google_sql_database.{charset,collation} as computed instead of having defaults.

This change is required to avoid the following scenario:
When upgrading from a previous version of the Google provider, TF will change
the charset/collation of existing (TF-managed) databases to utf8/utf8_general_ci
(if the user hasn't added different config values before running TF apply),
potentially overriding any non-default settings that the user my have applied
through the Cloud SQL admin API. This violates POLA.

* Remove charset/collation defaults from the documentation, too.

* Add links to MySQL's and PostgreSQL's documentation about supported charset and collation values.

* Use version 5.7's docs instead of 5.6, since that's the most up to date version of MySQL that we support.

* Add a note that only UTF8 / en_US.UTF8 are currently supported for Cloud SQL PostgreSQL databases.
2017-08-08 14:32:16 -07:00

2.3 KiB

layout page_title sidebar_current description
google Google: google_sql_database docs-google-sql-database-x 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 charset value. See MySQL's Supported Character Sets and Collations and PostgreSQL's Character Set Support for more details and supported values. Note that Cloud SQL's beta offering for PostgreSQL databases currently only supports the charset value UTF8.

  • collation - (Optional) The collation value. See MySQL's Supported Character Sets and Collations and PostgreSQL's Collation Support for more details and supported values. Note that Cloud SQL's beta offering for PostgreSQL databases currently only supports the collation value en_US.UTF8.

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