--- # ---------------------------------------------------------------------------- # # *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** # # ---------------------------------------------------------------------------- # # This file is automatically generated by Magic Modules and manual # changes will be clobbered when the file is regenerated. # # Please read more about how to change this file in # .github/CONTRIBUTING.md. # # ---------------------------------------------------------------------------- layout: "google" page_title: "Google: google_spanner_database" sidebar_current: "docs-google-spanner-database" description: |- 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](https://cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases) * How-to Guides * [Official Documentation](https://cloud.google.com/spanner/)
Open in Cloud Shell
## Example Usage - Spanner Database Basic ```hcl 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](/docs/configuration/resources.html#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.