Skip to content

Commit 728a999

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

File tree

2 files changed

+59
-52
lines changed

2 files changed

+59
-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
+58-52
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,89 @@
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 MySQL charset value.
4752

48-
- - -
53+
* `collation` -
54+
(Optional)
55+
The MySQL collation value.
4956

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

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.
5860

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.
6461

65-
## Attributes Reference
62+
## Timeouts
6663

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

70-
* `self_link` - The URI of the created resource.
67+
- `create` - Default is 15 minutes.
68+
- `update` - Default is 10 minutes.
69+
- `delete` - Default is 10 minutes.
7170

7271
## Import
7372

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

7675
```
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-
76+
$ terraform import google_sql_database.default projects/{{project}}/instances/{{instance}}/databases/{{name}}
77+
$ terraform import google_sql_database.default instances/{{instance}}/databases/{{name}}
78+
$ terraform import google_sql_database.default {{project}}/{{instance}}/{{name}}
79+
$ terraform import google_sql_database.default {{instance}}/{{name}}
80+
$ terraform import google_sql_database.default {{instance}}:{{name}}
81+
$ terraform import google_sql_database.default {{name}}
8382
```
83+
84+
-> If you're importing a resource with beta features, make sure to include `-provider=google-beta`
85+
as an argument so that Terraform uses the correct provider to import your resource.
86+
87+
## User Project Overrides
88+
89+
This resource supports [User Project Overrides](https://www.terraform.io/docs/providers/google/provider_reference.html#user_project_override).

0 commit comments

Comments
 (0)