Skip to content

Commit f30a325

Browse files
rileykarsonmodular-magician
authored andcommitted
Fix for SQL database import formats
Signed-off-by: Modular Magician <[email protected]>
1 parent 10edf03 commit f30a325

File tree

2 files changed

+67
-52
lines changed

2 files changed

+67
-52
lines changed

google/resource_sql_database.go

+1
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ func resourceSqlDatabaseImport(d *schema.ResourceData, meta interface{}) ([]*sch
318318
"instances/(?P<instance>[^/]+)/databases/(?P<name>[^/]+)",
319319
"(?P<project>[^/]+)/(?P<instance>[^/]+)/(?P<name>[^/]+)",
320320
"(?P<instance>[^/]+)/(?P<name>[^/]+)",
321+
"(?P<instance>[^/]+):(?P<name>[^/]+)",
321322
"(?P<name>[^/]+)",
322323
}, d, config); err != nil {
323324
return nil, err
+66-52
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,97 @@
11
---
2+
# ----------------------------------------------------------------------------
3+
#
4+
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
5+
#
6+
# ----------------------------------------------------------------------------
7+
#
8+
# This file is automatically generated by Magic Modules and manual
9+
# changes will be clobbered when the file is regenerated.
10+
#
11+
# Please read more about how to change this file in
12+
# .github/CONTRIBUTING.md.
13+
#
14+
# ----------------------------------------------------------------------------
215
layout: "google"
316
page_title: "Google: google_sql_database"
4-
sidebar_current: "docs-google-sql-database-x"
17+
sidebar_current: "docs-google-sql-database"
518
description: |-
6-
Creates a new SQL database in Google Cloud SQL.
19+
Represents a SQL database inside the Cloud SQL instance, hosted in
20+
Google's cloud.
721
---
822

923
# google\_sql\_database
1024

11-
Creates a new Google SQL Database on a Google SQL Database Instance. For more information, see
12-
the [official documentation](https://cloud.google.com/sql/),
13-
or the [JSON API](https://cloud.google.com/sql/docs/admin-api/v1beta4/databases).
25+
Represents a SQL database inside the Cloud SQL instance, hosted in
26+
Google's cloud.
1427

15-
## Example Usage
1628

17-
Example creating a SQL Database.
1829

19-
```hcl
20-
resource "random_id" "db_name_suffix" {
21-
byte_length = 4
22-
}
30+
## Argument Reference
2331

24-
resource "google_sql_database_instance" "master" {
25-
name = "master-instance-${random_id.db_name_suffix.hex}"
32+
The following arguments are supported:
2633

27-
settings {
28-
tier = "D0"
29-
}
30-
}
3134

32-
resource "google_sql_database" "users" {
33-
name = "users-db"
34-
instance = "${google_sql_database_instance.master.name}"
35-
charset = "latin1"
36-
collation = "latin1_swedish_ci"
37-
}
38-
```
35+
* `name` -
36+
(Required)
37+
The name of the database in the Cloud SQL instance.
38+
This does not include the project ID or instance name.
3939

40-
## Argument Reference
40+
* `instance` -
41+
(Required)
42+
The name of the Cloud SQL instance. This does not include the project
43+
ID.
4144

42-
The following arguments are supported:
4345

44-
* `name` - (Required) The name of the database.
46+
- - -
47+
4548

46-
* `instance` - (Required) The name of containing instance.
49+
* `charset` -
50+
(Optional)
51+
The charset value. See MySQL's
52+
[Supported Character Sets and Collations](https://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html)
53+
and Postgres' [Character Set Support](https://www.postgresql.org/docs/9.6/static/multibyte.html)
54+
for more details and supported values. Postgres databases only support
55+
a value of `UTF8` at creation time.
4756

48-
- - -
57+
* `collation` -
58+
(Optional)
59+
The collation value. See MySQL's
60+
[Supported Character Sets and Collations](https://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html)
61+
and Postgres' [Collation Support](https://www.postgresql.org/docs/9.6/static/collation.html)
62+
for more details and supported values. Postgres databases only support
63+
a value of `en_US.UTF8` at creation time.
4964

50-
* `project` - (Optional) The ID of the project in which the resource belongs. If it
51-
is not provided, the provider project is used.
65+
* `project` - (Optional) The ID of the project in which the resource belongs.
66+
If it is not provided, the provider project is used.
5267

53-
* `charset` - (Optional) The charset value. See MySQL's
54-
[Supported Character Sets and Collations](https://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html)
55-
and Postgres' [Character Set Support](https://www.postgresql.org/docs/9.6/static/multibyte.html)
56-
for more details and supported values. Postgres databases are in beta
57-
and have limited `charset` support; they only support a value of `UTF8` at creation time.
5868

59-
* `collation` - (Optional) The collation value. See MySQL's
60-
[Supported Character Sets and Collations](https://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html)
61-
and Postgres' [Collation Support](https://www.postgresql.org/docs/9.6/static/collation.html)
62-
for more details and supported values. Postgres databases are in beta
63-
and have limited `collation` support; they only support a value of `en_US.UTF8` at creation time.
6469

65-
## Attributes Reference
70+
## Timeouts
6671

67-
In addition to the arguments listed above, the following computed attributes are
68-
exported:
72+
This resource provides the following
73+
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:
6974

70-
* `self_link` - The URI of the created resource.
75+
- `create` - Default is 15 minutes.
76+
- `update` - Default is 10 minutes.
77+
- `delete` - Default is 10 minutes.
7178

7279
## Import
7380

74-
SQL databases can be imported using one of any of these accepted formats:
81+
Database can be imported using any of these accepted formats:
7582

7683
```
77-
$ terraform import google_sql_database.database projects/{{project}}/instances/{{instance}}/databases/{{name}}
78-
$ terraform import google_sql_database.database {{project}}/{{instance}}/{{name}}
79-
$ terraform import google_sql_database.database instances/{{name}}/databases/{{name}}
80-
$ terraform import google_sql_database.database {{instance}}/{{name}}
81-
$ terraform import google_sql_database.database {{name}}
82-
84+
$ terraform import google_sql_database.default projects/{{project}}/instances/{{instance}}/databases/{{name}}
85+
$ terraform import google_sql_database.default instances/{{instance}}/databases/{{name}}
86+
$ terraform import google_sql_database.default {{project}}/{{instance}}/{{name}}
87+
$ terraform import google_sql_database.default {{instance}}/{{name}}
88+
$ terraform import google_sql_database.default {{instance}}:{{name}}
89+
$ terraform import google_sql_database.default {{name}}
8390
```
91+
92+
-> If you're importing a resource with beta features, make sure to include `-provider=google-beta`
93+
as an argument so that Terraform uses the correct provider to import your resource.
94+
95+
## User Project Overrides
96+
97+
This resource supports [User Project Overrides](https://www.terraform.io/docs/providers/google/provider_reference.html#user_project_override).

0 commit comments

Comments
 (0)