Signed-off-by: Modular Magician <magic-modules@google.com>
3.8 KiB
layout | page_title | sidebar_current | description |
---|---|---|---|
Google: google_spanner_database | docs-google-spanner-database | A Cloud Spanner Database which is hosted on a Spanner instance. |
google_spanner_database
A Cloud Spanner Database which is hosted on a Spanner instance.
To get more information about Database, see:
- API documentation
- How-to Guides
resource "google_spanner_instance" "main" {
config = "regional-europe-west1"
display_name = "main-instance"
}
resource "google_spanner_database" "database" {
instance = "${google_spanner_instance.main.name}"
name = "my-database"
ddl = [
"CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
"CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)"
]
}
Argument Reference
The following arguments are supported:
-
name
- (Required) A unique identifier for the database, which cannot be changed after the instance is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9]. -
instance
- (Required) The instance to create the database on.
ddl
- (Optional) An optional list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.project
- (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Attributes Reference
In addition to the arguments listed above, the following computed attributes are exported:
state
- An explanation of the status of the database.
Timeouts
This resource provides the following Timeouts configuration options:
create
- Default is 4 minutes.delete
- Default is 4 minutes.
Import
Database can be imported using any of these accepted formats:
$ terraform import google_spanner_database.default projects/{{project}}/instances/{{instance}}/databases/{{name}}
$ terraform import google_spanner_database.default instances/{{instance}}/databases/{{name}}
$ terraform import google_spanner_database.default {{project}}/{{instance}}/{{name}}
$ terraform import google_spanner_database.default {{instance}}/{{name}}
-> If you're importing a resource with beta features, make sure to include -provider=google-beta
as an argument so that Terraform uses the correct provider to import your resource.