terraform-provider-google/r/sql_user.html.markdown
Riley Karson 9f1c31a843 provider/google: Add import support to google_sql_user (#14457)
* Support importing google_sql_user

* Updated documentation to reflect that passwords are not retrieved.

* Added additional documentation detailing use.

* Removed unneeded d.setId() line from GoogleSqlUser Read method.

* Changed an errors.New() call to fmt.Errorf().

* Migrate schemas of existing GoogleSqlUser resources.

* Remove explicitly setting 'id' property

* Added google_sql_user to importability page.

* Changed separator to '/' from '.' and updated tests + debug messages.
2017-05-22 13:43:10 -07:00

1.9 KiB

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

google_sql_user

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

~> Note: All arguments including the username and password will be stored in the raw state as plain-text. Read more about sensitive data in state. Passwords will not be retrieved when running "terraform import".

Example Usage

Example creating a SQL User.

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

  settings {
    tier = "D0"
  }
}

resource "google_sql_user" "users" {
  name     = "me"
  instance = "${google_sql_database_instance.master.name}"
  host     = "me.com"
  password = "changeme"
}

Argument Reference

The following arguments are supported:

  • host - (Required) The host the user can connect from. Can be an IP address. Changing this forces a new resource to be created.

  • instance - (Required) The name of the Cloud SQL instance. Changing this forces a new resource to be created.

  • name - (Required) The name of the user. Changing this forces a new resource to be created.

  • password - (Required) The users password. Can be updated.


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

Attributes Reference

Only the arguments listed above are exposed as attributes.

Import Format

Importing an SQL user is formatted as:

terraform import google_sql_user.$RESOURCENAME $INSTANCENAME/$SQLUSERNAME

For example, the sample at the top of this page could be imported with:

terraform import google_sql_user.users master-instance/me