2016-12-12 16:35:41 +01:00
|
|
|
---
|
|
|
|
layout: "postgresql"
|
|
|
|
page_title: "PostgreSQL: postgresql_schema"
|
|
|
|
sidebar_current: "docs-postgresql-resource-postgresql_schema"
|
|
|
|
description: |-
|
|
|
|
Creates and manages a schema within a PostgreSQL database.
|
|
|
|
---
|
|
|
|
|
|
|
|
# postgresql\_schema
|
|
|
|
|
|
|
|
The ``postgresql_schema`` resource creates and manages a schema within a
|
|
|
|
PostgreSQL database.
|
|
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```
|
|
|
|
resource "postgresql_schema" "my_schema" {
|
2016-12-14 10:04:35 +01:00
|
|
|
name = "my_schema"
|
|
|
|
owner = "postgres"
|
2016-12-12 16:35:41 +01:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
* `name` - (Required) The name of the schema. Must be unique in the PostgreSQL
|
|
|
|
database instance where it is configured.
|
|
|
|
|
2016-12-14 10:04:35 +01:00
|
|
|
* `owner` - (Optional) The ROLE who owns the schema.
|
|
|
|
|
2016-12-12 16:35:41 +01:00
|
|
|
## Import Example
|
|
|
|
|
|
|
|
`postgresql_schema` supports importing resources. Supposing the following
|
|
|
|
Terraform:
|
|
|
|
|
|
|
|
```
|
2016-12-14 10:04:35 +01:00
|
|
|
resource "postgresql_schema" "public" {
|
|
|
|
name = "public"
|
2016-12-12 16:35:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "postgresql_schema" "schema_foo" {
|
2016-12-14 10:04:35 +01:00
|
|
|
name = "my_schema"
|
|
|
|
owner = "postgres"
|
2016-12-12 16:35:41 +01:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
It is possible to import a `postgresql_schema` resource with the following
|
|
|
|
command:
|
|
|
|
|
|
|
|
```
|
|
|
|
$ terraform import postgresql_schema.schema_foo my_schema
|
|
|
|
```
|
|
|
|
|
|
|
|
Where `my_schema` is the name of the schema in the PostgreSQL database and
|
|
|
|
`postgresql_schema.schema_foo` is the name of the resource whose state will be
|
|
|
|
populated as a result of the command.
|