|
1 | 1 | ---
|
| 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 | +# ---------------------------------------------------------------------------- |
2 | 15 | layout: "google"
|
3 | 16 | page_title: "Google: google_sql_database"
|
4 |
| -sidebar_current: "docs-google-sql-database-x" |
| 17 | +sidebar_current: "docs-google-sql-database" |
5 | 18 | 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. |
7 | 21 | ---
|
8 | 22 |
|
9 | 23 | # google\_sql\_database
|
10 | 24 |
|
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. |
14 | 27 |
|
15 |
| -## Example Usage |
16 | 28 |
|
17 |
| -Example creating a SQL Database. |
18 | 29 |
|
19 |
| -```hcl |
20 |
| -resource "random_id" "db_name_suffix" { |
21 |
| - byte_length = 4 |
22 |
| -} |
| 30 | +<div class = "oics-button" style="float: right; margin: 0 0 -15px"> |
| 31 | + <a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.jpy.wang%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=sql_database_basic&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank"> |
| 32 | + <img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> |
| 33 | + </a> |
| 34 | +</div> |
| 35 | +## Example Usage - Sql Database Basic |
23 | 36 |
|
24 |
| -resource "google_sql_database_instance" "master" { |
25 |
| - name = "master-instance-${random_id.db_name_suffix.hex}" |
26 | 37 |
|
27 |
| - settings { |
28 |
| - tier = "D0" |
29 |
| - } |
| 38 | +```hcl |
| 39 | +resource "google_sql_database" "database" { |
| 40 | + name = "my-database" |
| 41 | + instance = "${google_sql_database_instance.instance.name}" |
30 | 42 | }
|
31 | 43 |
|
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" |
| 44 | +resource "google_sql_database_instance" "instance" { |
| 45 | + name = "my-database-instance" |
| 46 | + region = "us-central" |
| 47 | + settings { |
| 48 | + tier = "D0" |
| 49 | + } |
37 | 50 | }
|
38 | 51 | ```
|
39 | 52 |
|
40 | 53 | ## Argument Reference
|
41 | 54 |
|
42 | 55 | The following arguments are supported:
|
43 | 56 |
|
44 |
| -* `name` - (Required) The name of the database. |
45 | 57 |
|
46 |
| -* `instance` - (Required) The name of containing instance. |
| 58 | +* `name` - |
| 59 | + (Required) |
| 60 | + The name of the database in the Cloud SQL instance. |
| 61 | + This does not include the project ID or instance name. |
| 62 | + |
| 63 | +* `instance` - |
| 64 | + (Required) |
| 65 | + The name of the Cloud SQL instance. This does not include the project |
| 66 | + ID. |
| 67 | + |
47 | 68 |
|
48 | 69 | - - -
|
49 | 70 |
|
50 |
| -* `project` - (Optional) The ID of the project in which the resource belongs. If it |
51 |
| - is not provided, the provider project is used. |
52 | 71 |
|
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. |
| 72 | +* `charset` - |
| 73 | + (Optional) |
| 74 | + The charset value. See MySQL's |
| 75 | + [Supported Character Sets and Collations](https://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html) |
| 76 | + and Postgres' [Character Set Support](https://www.postgresql.org/docs/9.6/static/multibyte.html) |
| 77 | + for more details and supported values. Postgres databases only support |
| 78 | + a value of `UTF8` at creation time. |
| 79 | + |
| 80 | +* `collation` - |
| 81 | + (Optional) |
| 82 | + The collation value. See MySQL's |
| 83 | + [Supported Character Sets and Collations](https://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html) |
| 84 | + and Postgres' [Collation Support](https://www.postgresql.org/docs/9.6/static/collation.html) |
| 85 | + for more details and supported values. Postgres databases only support |
| 86 | + a value of `en_US.UTF8` at creation time. |
58 | 87 |
|
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. |
| 88 | +* `project` - (Optional) The ID of the project in which the resource belongs. |
| 89 | + If it is not provided, the provider project is used. |
64 | 90 |
|
65 |
| -## Attributes Reference |
66 | 91 |
|
67 |
| -In addition to the arguments listed above, the following computed attributes are |
68 |
| -exported: |
69 | 92 |
|
70 |
| -* `self_link` - The URI of the created resource. |
| 93 | +## Timeouts |
| 94 | + |
| 95 | +This resource provides the following |
| 96 | +[Timeouts](/docs/configuration/resources.html#timeouts) configuration options: |
| 97 | + |
| 98 | +- `create` - Default is 15 minutes. |
| 99 | +- `update` - Default is 10 minutes. |
| 100 | +- `delete` - Default is 10 minutes. |
71 | 101 |
|
72 | 102 | ## Import
|
73 | 103 |
|
74 |
| -SQL databases can be imported using one of any of these accepted formats: |
| 104 | +Database can be imported using any of these accepted formats: |
75 | 105 |
|
76 | 106 | ```
|
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 |
| -
|
| 107 | +$ terraform import google_sql_database.default projects/{{project}}/instances/{{instance}}/databases/{{name}} |
| 108 | +$ terraform import google_sql_database.default instances/{{instance}}/databases/{{name}} |
| 109 | +$ terraform import google_sql_database.default {{project}}/{{instance}}/{{name}} |
| 110 | +$ terraform import google_sql_database.default {{instance}}/{{name}} |
| 111 | +$ terraform import google_sql_database.default {{instance}}:{{name}} |
| 112 | +$ terraform import google_sql_database.default {{name}} |
83 | 113 | ```
|
| 114 | + |
| 115 | +-> If you're importing a resource with beta features, make sure to include `-provider=google-beta` |
| 116 | +as an argument so that Terraform uses the correct provider to import your resource. |
| 117 | + |
| 118 | +## User Project Overrides |
| 119 | + |
| 120 | +This resource supports [User Project Overrides](https://www.terraform.io/docs/providers/google/provider_reference.html#user_project_override). |
0 commit comments