Skip to content

Commit 560e180

Browse files
Allow use of provider region, with big caveats in docs. (#1463)
1 parent 105709b commit 560e180

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

google/resource_sql_database_instance.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func resourceSqlDatabaseInstance() *schema.Resource {
5151
Schema: map[string]*schema.Schema{
5252
"region": &schema.Schema{
5353
Type: schema.TypeString,
54-
Required: true,
54+
Optional: true,
5555
ForceNew: true,
5656
},
5757

@@ -423,7 +423,10 @@ func resourceSqlDatabaseInstanceCreate(d *schema.ResourceData, meta interface{})
423423
return err
424424
}
425425

426-
region := d.Get("region").(string)
426+
region, err := getRegion(d, config)
427+
if err != nil {
428+
return err
429+
}
427430
databaseVersion := d.Get("database_version").(string)
428431

429432
_settingsList := d.Get("settings").([]interface{})

website/docs/r/sql_database_instance.html.markdown

+4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ The following arguments are supported:
5959
* `region` - (Required) The region the instance will sit in. Note, first-generation Cloud SQL instance
6060
regions do not line up with the Google Compute Engine (GCE) regions, and Cloud SQL is not
6161
available in all regions - choose from one of the options listed [here](https://cloud.google.com/sql/docs/mysql/instance-locations).
62+
A valid region must be provided to use this resource. If a region is not provided in the resource definition,
63+
the provider region will be used instead, but this will be an apply-time error for all first-generation
64+
instances *and* for second-generation instances if the provider region is not supported with Cloud SQL.
65+
If you choose not to provide the `region` argument for this resource, make sure you understand this.
6266

6367
* `settings` - (Required) The settings to use for the database. The
6468
configuration is detailed below.

0 commit comments

Comments
 (0)