From 47528f1663c1fdd41e6b18b22006522213ebdae6 Mon Sep 17 00:00:00 2001 From: Vincent Roseberry Date: Fri, 9 Feb 2018 13:43:49 -0800 Subject: [PATCH] Support multiple users with the same name for different host for 1st gen. (#1066) * Support multiple users with the same name for different host for 1st gen. * Fix typo and rename user --- docs/r/sql_database_instance.html.markdown | 24 ++++++++++++++++++++-- docs/r/sql_user.html.markdown | 15 ++++++++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/docs/r/sql_database_instance.html.markdown b/docs/r/sql_database_instance.html.markdown index 77dc4c52355..b9eb0e2c8dc 100644 --- a/docs/r/sql_database_instance.html.markdown +++ b/docs/r/sql_database_instance.html.markdown @@ -19,12 +19,15 @@ a restricted host and strong password. ## Example Usage -Example creating a SQL Database. +### SQL First Generation ```hcl resource "google_sql_database_instance" "master" { name = "master-instance" - database_version = "POSTGRES_9_6" + database_version = "MYSQL_5_6" + # First-generation instance regions are not the conventional + # Google Compute Engine regions. See argument reference below. + region = "us-central" settings { tier = "D0" @@ -32,6 +35,23 @@ resource "google_sql_database_instance" "master" { } ``` + +### SQL Second generation + +```hcl +resource "google_sql_database_instance" "master" { + name = "master-instance" + database_version = "POSTGRES_9_6" + region = "us-central1" + + settings { + # Second-generation instance tiers are based on the machine + # type. See argument reference below. + tier = "db-f1-micro" + } +} +``` + ## Argument Reference The following arguments are supported: diff --git a/docs/r/sql_user.html.markdown b/docs/r/sql_user.html.markdown index 8558515a238..65f41f238c6 100644 --- a/docs/r/sql_user.html.markdown +++ b/docs/r/sql_user.html.markdown @@ -39,9 +39,6 @@ resource "google_sql_user" "users" { 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. @@ -52,6 +49,10 @@ The following arguments are supported: - - - +* `host` - (Optional) The host the user can connect from. This is only supported + for first generation SQL instances. Don't set this field for second generation + SQL instances. Can be an IP address. Changing this forces a new resource to be created. + * `project` - (Optional) The project in which the resource belongs. If it is not provided, the provider project is used. @@ -61,7 +62,13 @@ Only the arguments listed above are exposed as attributes. ## Import -SQL users can be imported using the `instance` and `name`, e.g. +SQL users for 1st generation databases can be imported using the `instance`, `host` and `name`, e.g. + +``` +$ terraform import google_sql_user.users master-instance/my-domain.com/me +``` + +SQL users for 2nd generation databases can be imported using the `instance` and `name`, e.g. ``` $ terraform import google_sql_user.users master-instance/me