Schema
The postgresql..Schema resource creates and manages schema
objects within
a PostgreSQL database.
Usage
import * as pulumi from "@pulumi/pulumi";
import * as postgresql from "@pulumi/postgresql";
const appWww = new postgresql.Role("app_www", {});
const appDba = new postgresql.Role("app_dba", {});
const appReleng = new postgresql.Role("app_releng", {});
const mySchema = new postgresql.Schema("my_schema", {
owner: "postgres",
policies: [
{
role: appWww.name,
usage: true,
},
// app_releng can create new objects in the schema. This is the role that
// migrations are executed as.
{
create: true,
role: appReleng.name,
usage: true,
},
{
createWithGrant: true,
role: appDba.name,
usageWithGrant: true,
},
],
});import pulumi
import pulumi_postgresql as postgresql
app_www = postgresql.Role("appWww")
app_dba = postgresql.Role("appDba")
app_releng = postgresql.Role("appReleng")
my_schema = postgresql.Schema("mySchema",
owner="postgres",
policies=[
{
"role": app_www.name,
"usage": True,
},
{
"create": True,
"role": app_releng.name,
"usage": True,
},
{
"createWithGrant": True,
"role": app_dba.name,
"usageWithGrant": True,
},
])using Pulumi;
using PostgreSql = Pulumi.PostgreSql;
class MyStack : Stack
{
public MyStack()
{
var appWww = new PostgreSql.Role("appWww", new PostgreSql.RoleArgs
{
});
var appDba = new PostgreSql.Role("appDba", new PostgreSql.RoleArgs
{
});
var appReleng = new PostgreSql.Role("appReleng", new PostgreSql.RoleArgs
{
});
var mySchema = new PostgreSql.Schema("mySchema", new PostgreSql.SchemaArgs
{
Owner = "postgres",
Policies =
{
new PostgreSql.Inputs.SchemaPolicyArgs
{
Role = appWww.Name,
Usage = true,
},
new PostgreSql.Inputs.SchemaPolicyArgs
{
Create = true,
Role = appReleng.Name,
Usage = true,
},
new PostgreSql.Inputs.SchemaPolicyArgs
{
CreateWithGrant = true,
Role = appDba.Name,
UsageWithGrant = true,
},
},
});
}
}
Create a Schema Resource
new Schema(name: string, args?: SchemaArgs, opts?: CustomResourceOptions);def Schema(resource_name, opts=None, database=None, drop_cascade=None, if_not_exists=None, name=None, owner=None, policies=None, __props__=None);func NewSchema(ctx *Context, name string, args *SchemaArgs, opts ...ResourceOption) (*Schema, error)public Schema(string name, SchemaArgs? args = null, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args SchemaArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args SchemaArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SchemaArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
Schema Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The Schema resource accepts the following input properties:
- Database string
The DATABASE in which where this schema will be created. (Default: The database used by your
providerconfiguration)- Drop
Cascade bool When true, will also drop all the objects that are contained in the schema. (Default: false)
- If
Not boolExists When true, use the existing schema if it exists. (Default: true)
- Name string
The name of the schema. Must be unique in the PostgreSQL database instance where it is configured.
- Owner string
The ROLE who owns the schema.
- Policies
List<Pulumi.
Postgre Sql. Inputs. Schema Policy Args> Can be specified multiple times for each policy. Each policy block supports fields documented below.
- Database string
The DATABASE in which where this schema will be created. (Default: The database used by your
providerconfiguration)- Drop
Cascade bool When true, will also drop all the objects that are contained in the schema. (Default: false)
- If
Not boolExists When true, use the existing schema if it exists. (Default: true)
- Name string
The name of the schema. Must be unique in the PostgreSQL database instance where it is configured.
- Owner string
The ROLE who owns the schema.
- Policies
[]Schema
Policy Can be specified multiple times for each policy. Each policy block supports fields documented below.
- database string
The DATABASE in which where this schema will be created. (Default: The database used by your
providerconfiguration)- drop
Cascade boolean When true, will also drop all the objects that are contained in the schema. (Default: false)
- if
Not booleanExists When true, use the existing schema if it exists. (Default: true)
- name string
The name of the schema. Must be unique in the PostgreSQL database instance where it is configured.
- owner string
The ROLE who owns the schema.
- policies
Schema
Policy[] Can be specified multiple times for each policy. Each policy block supports fields documented below.
- database str
The DATABASE in which where this schema will be created. (Default: The database used by your
providerconfiguration)- drop_
cascade bool When true, will also drop all the objects that are contained in the schema. (Default: false)
- if_
not_ boolexists When true, use the existing schema if it exists. (Default: true)
- name str
The name of the schema. Must be unique in the PostgreSQL database instance where it is configured.
- owner str
The ROLE who owns the schema.
- policies
List[Schema
Policy] Can be specified multiple times for each policy. Each policy block supports fields documented below.
Outputs
All input properties are implicitly available as output properties. Additionally, the Schema resource produces the following output properties:
Look up an Existing Schema Resource
Get an existing Schema resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: SchemaState, opts?: CustomResourceOptions): Schemastatic get(resource_name, id, opts=None, database=None, drop_cascade=None, if_not_exists=None, name=None, owner=None, policies=None, __props__=None);func GetSchema(ctx *Context, name string, id IDInput, state *SchemaState, opts ...ResourceOption) (*Schema, error)public static Schema Get(string name, Input<string> id, SchemaState? state, CustomResourceOptions? opts = null)- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
The following state arguments are supported:
- Database string
The DATABASE in which where this schema will be created. (Default: The database used by your
providerconfiguration)- Drop
Cascade bool When true, will also drop all the objects that are contained in the schema. (Default: false)
- If
Not boolExists When true, use the existing schema if it exists. (Default: true)
- Name string
The name of the schema. Must be unique in the PostgreSQL database instance where it is configured.
- Owner string
The ROLE who owns the schema.
- Policies
List<Pulumi.
Postgre Sql. Inputs. Schema Policy Args> Can be specified multiple times for each policy. Each policy block supports fields documented below.
- Database string
The DATABASE in which where this schema will be created. (Default: The database used by your
providerconfiguration)- Drop
Cascade bool When true, will also drop all the objects that are contained in the schema. (Default: false)
- If
Not boolExists When true, use the existing schema if it exists. (Default: true)
- Name string
The name of the schema. Must be unique in the PostgreSQL database instance where it is configured.
- Owner string
The ROLE who owns the schema.
- Policies
[]Schema
Policy Can be specified multiple times for each policy. Each policy block supports fields documented below.
- database string
The DATABASE in which where this schema will be created. (Default: The database used by your
providerconfiguration)- drop
Cascade boolean When true, will also drop all the objects that are contained in the schema. (Default: false)
- if
Not booleanExists When true, use the existing schema if it exists. (Default: true)
- name string
The name of the schema. Must be unique in the PostgreSQL database instance where it is configured.
- owner string
The ROLE who owns the schema.
- policies
Schema
Policy[] Can be specified multiple times for each policy. Each policy block supports fields documented below.
- database str
The DATABASE in which where this schema will be created. (Default: The database used by your
providerconfiguration)- drop_
cascade bool When true, will also drop all the objects that are contained in the schema. (Default: false)
- if_
not_ boolexists When true, use the existing schema if it exists. (Default: true)
- name str
The name of the schema. Must be unique in the PostgreSQL database instance where it is configured.
- owner str
The ROLE who owns the schema.
- policies
List[Schema
Policy] Can be specified multiple times for each policy. Each policy block supports fields documented below.
Supporting Types
SchemaPolicy
- Create bool
Should the specified ROLE have CREATE privileges to the specified SCHEMA.
- Create
With boolGrant Should the specified ROLE have CREATE privileges to the specified SCHEMA and the ability to GRANT the CREATE privilege to other ROLEs.
- Role string
The ROLE who is receiving the policy. If this value is empty or not specified it implies the policy is referring to the
PUBLICrole.- Usage bool
Should the specified ROLE have USAGE privileges to the specified SCHEMA.
- Usage
With boolGrant Should the specified ROLE have USAGE privileges to the specified SCHEMA and the ability to GRANT the USAGE privilege to other ROLEs.
- Create bool
Should the specified ROLE have CREATE privileges to the specified SCHEMA.
- Create
With boolGrant Should the specified ROLE have CREATE privileges to the specified SCHEMA and the ability to GRANT the CREATE privilege to other ROLEs.
- Role string
The ROLE who is receiving the policy. If this value is empty or not specified it implies the policy is referring to the
PUBLICrole.- Usage bool
Should the specified ROLE have USAGE privileges to the specified SCHEMA.
- Usage
With boolGrant Should the specified ROLE have USAGE privileges to the specified SCHEMA and the ability to GRANT the USAGE privilege to other ROLEs.
- create boolean
Should the specified ROLE have CREATE privileges to the specified SCHEMA.
- create
With booleanGrant Should the specified ROLE have CREATE privileges to the specified SCHEMA and the ability to GRANT the CREATE privilege to other ROLEs.
- role string
The ROLE who is receiving the policy. If this value is empty or not specified it implies the policy is referring to the
PUBLICrole.- usage boolean
Should the specified ROLE have USAGE privileges to the specified SCHEMA.
- usage
With booleanGrant Should the specified ROLE have USAGE privileges to the specified SCHEMA and the ability to GRANT the USAGE privilege to other ROLEs.
- create bool
Should the specified ROLE have CREATE privileges to the specified SCHEMA.
- create
With boolGrant Should the specified ROLE have CREATE privileges to the specified SCHEMA and the ability to GRANT the CREATE privilege to other ROLEs.
- role str
The ROLE who is receiving the policy. If this value is empty or not specified it implies the policy is referring to the
PUBLICrole.- usage bool
Should the specified ROLE have USAGE privileges to the specified SCHEMA.
- usage
With boolGrant Should the specified ROLE have USAGE privileges to the specified SCHEMA and the ability to GRANT the USAGE privilege to other ROLEs.
Package Details
- Repository
- https://github.com/pulumi/pulumi-postgresql
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
postgresqlTerraform Provider.