2017-08-14 16:53:11 +00:00
|
|
|
---
|
2019-01-16 21:42:38 +00:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# *** 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.
|
|
|
|
#
|
|
|
|
# ----------------------------------------------------------------------------
|
2017-08-14 16:53:11 +00:00
|
|
|
layout: "google"
|
|
|
|
page_title: "Google: google_spanner_database"
|
|
|
|
sidebar_current: "docs-google-spanner-database"
|
|
|
|
description: |-
|
2019-01-16 21:42:38 +00:00
|
|
|
A Cloud Spanner Database which is hosted on a Spanner instance.
|
2017-08-14 16:53:11 +00:00
|
|
|
---
|
|
|
|
|
2018-10-31 00:54:32 +00:00
|
|
|
# google\_spanner\_database
|
2017-08-14 16:53:11 +00:00
|
|
|
|
2019-01-16 21:42:38 +00:00
|
|
|
A Cloud Spanner Database which is hosted on a Spanner instance.
|
2017-08-14 16:53:11 +00:00
|
|
|
|
|
|
|
|
2019-01-16 21:42:38 +00:00
|
|
|
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/)
|
|
|
|
|
|
|
|
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
|
|
|
|
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=spanner_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">
|
|
|
|
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
## Example Usage - Spanner Database Basic
|
|
|
|
|
2017-08-14 16:53:11 +00:00
|
|
|
|
|
|
|
```hcl
|
|
|
|
resource "google_spanner_instance" "main" {
|
|
|
|
config = "regional-europe-west1"
|
|
|
|
display_name = "main-instance"
|
|
|
|
}
|
|
|
|
|
2019-01-16 21:42:38 +00:00
|
|
|
resource "google_spanner_database" "database" {
|
2017-08-14 16:53:11 +00:00
|
|
|
instance = "${google_spanner_instance.main.name}"
|
2019-01-16 21:42:38 +00:00
|
|
|
name = "my-database"
|
2017-08-14 16:53:11 +00:00
|
|
|
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:
|
|
|
|
|
|
|
|
|
2019-01-16 21:42:38 +00:00
|
|
|
* `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.
|
|
|
|
|
2017-08-14 16:53:11 +00:00
|
|
|
|
|
|
|
- - -
|
|
|
|
|
|
|
|
|
2019-01-16 21:42:38 +00:00
|
|
|
* `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.
|
2017-08-14 16:53:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
## Attributes Reference
|
|
|
|
|
2019-01-16 21:42:38 +00:00
|
|
|
In addition to the arguments listed above, the following computed attributes are exported:
|
2017-08-14 16:53:11 +00:00
|
|
|
|
|
|
|
|
2019-01-16 21:42:38 +00:00
|
|
|
* `state` -
|
|
|
|
An explanation of the status of the database.
|
2017-08-14 16:53:11 +00:00
|
|
|
|
|
|
|
|
2019-01-16 21:42:38 +00:00
|
|
|
## Timeouts
|
2017-08-14 16:53:11 +00:00
|
|
|
|
2019-01-16 21:42:38 +00:00
|
|
|
This resource provides the following
|
|
|
|
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:
|
2017-08-14 16:53:11 +00:00
|
|
|
|
2019-01-16 21:42:38 +00:00
|
|
|
- `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}}
|
2017-08-14 16:53:11 +00:00
|
|
|
```
|
2019-01-16 21:42:38 +00:00
|
|
|
|
|
|
|
-> 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.
|