Skip to content

Commit

Permalink
Add google_spanner_database docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nickithewatt committed Jul 31, 2017
1 parent 76d7bb5 commit 91baff7
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
68 changes: 68 additions & 0 deletions website/docs/r/spanner_database.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
layout: "google"
page_title: "Google: google_spanner_database"
sidebar_current: "docs-google-spanner-database"
description: |-
Creates a Google Spanner Database within a Spanner Instance.
---

# google\_spanner\_instance

Creates a Google Spanner Database within a Spanner Instance. For more information, see the [official documentation](https://cloud.google.com/spanner/), or the [JSON API](https://cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases).

## Example Usage

Example creating a Spanner database.

```hcl
resource "google_spanner_instance" "main" {
config = "regional-europe-west1"
display_name = "main-instance"
}
resource "google_spanner_database" "db" {
instance = "${google_spanner_instance.main.name}"
name = "main-instance"
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:

* `instance` - (Required) The name of the instance that will serve the new database.

* `name` - (Required) The name of the database.

- - -

* `project` - (Optional) The project in which to look for the `instance` specified. If it
is not provided, the provider project is used.

* `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.


## Attributes Reference

No additional attributes are computed other than those defined above.

## Import

Databases can be imported via their `instance` and `name` values, and optionally
the `project` in which the instance is defined (Often used when the project is different
to that defined in the provider). The format is thus either `{instanceName}/{dbName}` or
`{projectId}/{instanceName}/{dbName}`. e.g.

```
$ terraform import google_spanner_database.db1 instance456/db789
$ terraform import google_spanner_database.db1 project123/instance456/db789
```
4 changes: 4 additions & 0 deletions website/google.erb
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@
<li<%= sidebar_current("docs-google-spanner-instance") %>>
<a href="/docs/providers/google/r/spanner_instance.html">google_spanner_instance</a>
</li>

<li<%= sidebar_current("docs-google-spanner-database") %>>
<a href="/docs/providers/google/r/spanner_database.html">google_spanner_database</a>
</li>
</ul>
</li>

Expand Down

0 comments on commit 91baff7

Please sign in to comment.