mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-07 01:26:43 +00:00
115 lines
3.8 KiB
Markdown
115 lines
3.8 KiB
Markdown
---
|
|
# ----------------------------------------------------------------------------
|
|
#
|
|
# *** 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/)
|
|
|
|
<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
|
|
|
|
|
|
```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.
|