published on Friday, Apr 10, 2026 by Pulumi
published on Friday, Apr 10, 2026 by Pulumi
The postgresql.Database resource creates and manages database
objects
within a PostgreSQL server instance.
Usage
import * as pulumi from "@pulumi/pulumi";
import * as postgresql from "@pulumi/postgresql";
const myDb = new postgresql.Database("my_db", {
name: "my_db",
owner: "my_role",
template: "template0",
lcCollate: "C",
connectionLimit: -1,
allowConnections: true,
alterObjectOwnership: true,
});
import pulumi
import pulumi_postgresql as postgresql
my_db = postgresql.Database("my_db",
name="my_db",
owner="my_role",
template="template0",
lc_collate="C",
connection_limit=-1,
allow_connections=True,
alter_object_ownership=True)
package main
import (
"github.com/pulumi/pulumi-postgresql/sdk/v3/go/postgresql"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := postgresql.NewDatabase(ctx, "my_db", &postgresql.DatabaseArgs{
Name: pulumi.String("my_db"),
Owner: pulumi.String("my_role"),
Template: pulumi.String("template0"),
LcCollate: pulumi.String("C"),
ConnectionLimit: pulumi.Int(-1),
AllowConnections: pulumi.Bool(true),
AlterObjectOwnership: pulumi.Bool(true),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using PostgreSql = Pulumi.PostgreSql;
return await Deployment.RunAsync(() =>
{
var myDb = new PostgreSql.Index.Database("my_db", new()
{
Name = "my_db",
Owner = "my_role",
Template = "template0",
LcCollate = "C",
ConnectionLimit = -1,
AllowConnections = true,
AlterObjectOwnership = true,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.postgresql.Database;
import com.pulumi.postgresql.DatabaseArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var myDb = new Database("myDb", DatabaseArgs.builder()
.name("my_db")
.owner("my_role")
.template("template0")
.lcCollate("C")
.connectionLimit(-1)
.allowConnections(true)
.alterObjectOwnership(true)
.build());
}
}
resources:
myDb:
type: postgresql:Database
name: my_db
properties:
name: my_db
owner: my_role
template: template0
lcCollate: C
connectionLimit: -1
allowConnections: true
alterObjectOwnership: true
Create Database Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Database(name: string, args?: DatabaseArgs, opts?: CustomResourceOptions);@overload
def Database(resource_name: str,
args: Optional[DatabaseArgs] = None,
opts: Optional[ResourceOptions] = None)
@overload
def Database(resource_name: str,
opts: Optional[ResourceOptions] = None,
allow_connections: Optional[bool] = None,
alter_object_ownership: Optional[bool] = None,
connection_limit: Optional[int] = None,
encoding: Optional[str] = None,
is_template: Optional[bool] = None,
lc_collate: Optional[str] = None,
lc_ctype: Optional[str] = None,
name: Optional[str] = None,
owner: Optional[str] = None,
tablespace_name: Optional[str] = None,
template: Optional[str] = None)func NewDatabase(ctx *Context, name string, args *DatabaseArgs, opts ...ResourceOption) (*Database, error)public Database(string name, DatabaseArgs? args = null, CustomResourceOptions? opts = null)
public Database(String name, DatabaseArgs args)
public Database(String name, DatabaseArgs args, CustomResourceOptions options)
type: postgresql:Database
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args DatabaseArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args DatabaseArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args DatabaseArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args DatabaseArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args DatabaseArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Database Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Database resource accepts the following input properties:
- Allow
Connections bool - If
falsethen no one can connect to this database. The default istrue, allowing connections (except as restricted by other mechanisms, such asGRANTorREVOKE CONNECT). - Alter
Object boolOwnership - If
true, the change of the databaseownerwill also include a reassignment of the ownership of preexisting objects like tables or sequences from the previous owner to the new one. If set tofalse(the default), then the previous databaseownerwill still hold the ownership of the objects in that database. To alter existing objects in the database, you must be a direct or indirect member of the specified role, or the username in the provider must be superuser. - Connection
Limit int - How many concurrent connections can be
established to this database.
-1(the default) means no limit. - Encoding string
- Character set encoding to use in the database.
Specify a string constant (e.g.
UTF8orSQL_ASCII), or an integer encoding number. If unset or set to an empty string the default encoding is set toUTF8. If set toDEFAULTTerraform will use the same encoding as the template database. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - Is
Template bool - If
true, then this database can be cloned by any user withCREATEDBprivileges; iffalse(the default), then only superusers or the owner of the database can clone it. - Lc
Collate string - Collation order (
LC_COLLATE) to use in the database. This affects the sort order applied to strings, e.g. in queries withORDER BY, as well as the order used in indexes on text columns. If unset or set to an empty string the default collation is set toC. If set toDEFAULTTerraform will use the same collation order as the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - Lc
Ctype string - Character classification (
LC_CTYPE) to use in the database. This affects the categorization of characters, e.g. lower, upper and digit. If unset or set to an empty string the default character classification is set toC. If set toDEFAULTTerraform will use the character classification of the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - Name string
- The name of the database. Must be unique on the PostgreSQL server instance where it is configured.
- Owner string
- The role name of the user who will own the database, or
DEFAULTto use the default (namely, the user executing the command). To create a database owned by another role or to change the owner of an existing database, you must be a direct or indirect member of the specified role, or the username in the provider is a superuser. - Tablespace
Name string - The name of the tablespace that will be
associated with the database, or
DEFAULTto use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. - Template string
- The name of the template database from which to create
the database, or
DEFAULTto use the default template (template0). NOTE: the default in Terraform istemplate0, nottemplate1. Changing this value will force the creation of a new resource as this value can only be changed when a database is created.
- Allow
Connections bool - If
falsethen no one can connect to this database. The default istrue, allowing connections (except as restricted by other mechanisms, such asGRANTorREVOKE CONNECT). - Alter
Object boolOwnership - If
true, the change of the databaseownerwill also include a reassignment of the ownership of preexisting objects like tables or sequences from the previous owner to the new one. If set tofalse(the default), then the previous databaseownerwill still hold the ownership of the objects in that database. To alter existing objects in the database, you must be a direct or indirect member of the specified role, or the username in the provider must be superuser. - Connection
Limit int - How many concurrent connections can be
established to this database.
-1(the default) means no limit. - Encoding string
- Character set encoding to use in the database.
Specify a string constant (e.g.
UTF8orSQL_ASCII), or an integer encoding number. If unset or set to an empty string the default encoding is set toUTF8. If set toDEFAULTTerraform will use the same encoding as the template database. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - Is
Template bool - If
true, then this database can be cloned by any user withCREATEDBprivileges; iffalse(the default), then only superusers or the owner of the database can clone it. - Lc
Collate string - Collation order (
LC_COLLATE) to use in the database. This affects the sort order applied to strings, e.g. in queries withORDER BY, as well as the order used in indexes on text columns. If unset or set to an empty string the default collation is set toC. If set toDEFAULTTerraform will use the same collation order as the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - Lc
Ctype string - Character classification (
LC_CTYPE) to use in the database. This affects the categorization of characters, e.g. lower, upper and digit. If unset or set to an empty string the default character classification is set toC. If set toDEFAULTTerraform will use the character classification of the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - Name string
- The name of the database. Must be unique on the PostgreSQL server instance where it is configured.
- Owner string
- The role name of the user who will own the database, or
DEFAULTto use the default (namely, the user executing the command). To create a database owned by another role or to change the owner of an existing database, you must be a direct or indirect member of the specified role, or the username in the provider is a superuser. - Tablespace
Name string - The name of the tablespace that will be
associated with the database, or
DEFAULTto use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. - Template string
- The name of the template database from which to create
the database, or
DEFAULTto use the default template (template0). NOTE: the default in Terraform istemplate0, nottemplate1. Changing this value will force the creation of a new resource as this value can only be changed when a database is created.
- allow
Connections Boolean - If
falsethen no one can connect to this database. The default istrue, allowing connections (except as restricted by other mechanisms, such asGRANTorREVOKE CONNECT). - alter
Object BooleanOwnership - If
true, the change of the databaseownerwill also include a reassignment of the ownership of preexisting objects like tables or sequences from the previous owner to the new one. If set tofalse(the default), then the previous databaseownerwill still hold the ownership of the objects in that database. To alter existing objects in the database, you must be a direct or indirect member of the specified role, or the username in the provider must be superuser. - connection
Limit Integer - How many concurrent connections can be
established to this database.
-1(the default) means no limit. - encoding String
- Character set encoding to use in the database.
Specify a string constant (e.g.
UTF8orSQL_ASCII), or an integer encoding number. If unset or set to an empty string the default encoding is set toUTF8. If set toDEFAULTTerraform will use the same encoding as the template database. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - is
Template Boolean - If
true, then this database can be cloned by any user withCREATEDBprivileges; iffalse(the default), then only superusers or the owner of the database can clone it. - lc
Collate String - Collation order (
LC_COLLATE) to use in the database. This affects the sort order applied to strings, e.g. in queries withORDER BY, as well as the order used in indexes on text columns. If unset or set to an empty string the default collation is set toC. If set toDEFAULTTerraform will use the same collation order as the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - lc
Ctype String - Character classification (
LC_CTYPE) to use in the database. This affects the categorization of characters, e.g. lower, upper and digit. If unset or set to an empty string the default character classification is set toC. If set toDEFAULTTerraform will use the character classification of the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - name String
- The name of the database. Must be unique on the PostgreSQL server instance where it is configured.
- owner String
- The role name of the user who will own the database, or
DEFAULTto use the default (namely, the user executing the command). To create a database owned by another role or to change the owner of an existing database, you must be a direct or indirect member of the specified role, or the username in the provider is a superuser. - tablespace
Name String - The name of the tablespace that will be
associated with the database, or
DEFAULTto use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. - template String
- The name of the template database from which to create
the database, or
DEFAULTto use the default template (template0). NOTE: the default in Terraform istemplate0, nottemplate1. Changing this value will force the creation of a new resource as this value can only be changed when a database is created.
- allow
Connections boolean - If
falsethen no one can connect to this database. The default istrue, allowing connections (except as restricted by other mechanisms, such asGRANTorREVOKE CONNECT). - alter
Object booleanOwnership - If
true, the change of the databaseownerwill also include a reassignment of the ownership of preexisting objects like tables or sequences from the previous owner to the new one. If set tofalse(the default), then the previous databaseownerwill still hold the ownership of the objects in that database. To alter existing objects in the database, you must be a direct or indirect member of the specified role, or the username in the provider must be superuser. - connection
Limit number - How many concurrent connections can be
established to this database.
-1(the default) means no limit. - encoding string
- Character set encoding to use in the database.
Specify a string constant (e.g.
UTF8orSQL_ASCII), or an integer encoding number. If unset or set to an empty string the default encoding is set toUTF8. If set toDEFAULTTerraform will use the same encoding as the template database. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - is
Template boolean - If
true, then this database can be cloned by any user withCREATEDBprivileges; iffalse(the default), then only superusers or the owner of the database can clone it. - lc
Collate string - Collation order (
LC_COLLATE) to use in the database. This affects the sort order applied to strings, e.g. in queries withORDER BY, as well as the order used in indexes on text columns. If unset or set to an empty string the default collation is set toC. If set toDEFAULTTerraform will use the same collation order as the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - lc
Ctype string - Character classification (
LC_CTYPE) to use in the database. This affects the categorization of characters, e.g. lower, upper and digit. If unset or set to an empty string the default character classification is set toC. If set toDEFAULTTerraform will use the character classification of the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - name string
- The name of the database. Must be unique on the PostgreSQL server instance where it is configured.
- owner string
- The role name of the user who will own the database, or
DEFAULTto use the default (namely, the user executing the command). To create a database owned by another role or to change the owner of an existing database, you must be a direct or indirect member of the specified role, or the username in the provider is a superuser. - tablespace
Name string - The name of the tablespace that will be
associated with the database, or
DEFAULTto use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. - template string
- The name of the template database from which to create
the database, or
DEFAULTto use the default template (template0). NOTE: the default in Terraform istemplate0, nottemplate1. Changing this value will force the creation of a new resource as this value can only be changed when a database is created.
- allow_
connections bool - If
falsethen no one can connect to this database. The default istrue, allowing connections (except as restricted by other mechanisms, such asGRANTorREVOKE CONNECT). - alter_
object_ boolownership - If
true, the change of the databaseownerwill also include a reassignment of the ownership of preexisting objects like tables or sequences from the previous owner to the new one. If set tofalse(the default), then the previous databaseownerwill still hold the ownership of the objects in that database. To alter existing objects in the database, you must be a direct or indirect member of the specified role, or the username in the provider must be superuser. - connection_
limit int - How many concurrent connections can be
established to this database.
-1(the default) means no limit. - encoding str
- Character set encoding to use in the database.
Specify a string constant (e.g.
UTF8orSQL_ASCII), or an integer encoding number. If unset or set to an empty string the default encoding is set toUTF8. If set toDEFAULTTerraform will use the same encoding as the template database. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - is_
template bool - If
true, then this database can be cloned by any user withCREATEDBprivileges; iffalse(the default), then only superusers or the owner of the database can clone it. - lc_
collate str - Collation order (
LC_COLLATE) to use in the database. This affects the sort order applied to strings, e.g. in queries withORDER BY, as well as the order used in indexes on text columns. If unset or set to an empty string the default collation is set toC. If set toDEFAULTTerraform will use the same collation order as the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - lc_
ctype str - Character classification (
LC_CTYPE) to use in the database. This affects the categorization of characters, e.g. lower, upper and digit. If unset or set to an empty string the default character classification is set toC. If set toDEFAULTTerraform will use the character classification of the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - name str
- The name of the database. Must be unique on the PostgreSQL server instance where it is configured.
- owner str
- The role name of the user who will own the database, or
DEFAULTto use the default (namely, the user executing the command). To create a database owned by another role or to change the owner of an existing database, you must be a direct or indirect member of the specified role, or the username in the provider is a superuser. - tablespace_
name str - The name of the tablespace that will be
associated with the database, or
DEFAULTto use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. - template str
- The name of the template database from which to create
the database, or
DEFAULTto use the default template (template0). NOTE: the default in Terraform istemplate0, nottemplate1. Changing this value will force the creation of a new resource as this value can only be changed when a database is created.
- allow
Connections Boolean - If
falsethen no one can connect to this database. The default istrue, allowing connections (except as restricted by other mechanisms, such asGRANTorREVOKE CONNECT). - alter
Object BooleanOwnership - If
true, the change of the databaseownerwill also include a reassignment of the ownership of preexisting objects like tables or sequences from the previous owner to the new one. If set tofalse(the default), then the previous databaseownerwill still hold the ownership of the objects in that database. To alter existing objects in the database, you must be a direct or indirect member of the specified role, or the username in the provider must be superuser. - connection
Limit Number - How many concurrent connections can be
established to this database.
-1(the default) means no limit. - encoding String
- Character set encoding to use in the database.
Specify a string constant (e.g.
UTF8orSQL_ASCII), or an integer encoding number. If unset or set to an empty string the default encoding is set toUTF8. If set toDEFAULTTerraform will use the same encoding as the template database. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - is
Template Boolean - If
true, then this database can be cloned by any user withCREATEDBprivileges; iffalse(the default), then only superusers or the owner of the database can clone it. - lc
Collate String - Collation order (
LC_COLLATE) to use in the database. This affects the sort order applied to strings, e.g. in queries withORDER BY, as well as the order used in indexes on text columns. If unset or set to an empty string the default collation is set toC. If set toDEFAULTTerraform will use the same collation order as the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - lc
Ctype String - Character classification (
LC_CTYPE) to use in the database. This affects the categorization of characters, e.g. lower, upper and digit. If unset or set to an empty string the default character classification is set toC. If set toDEFAULTTerraform will use the character classification of the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - name String
- The name of the database. Must be unique on the PostgreSQL server instance where it is configured.
- owner String
- The role name of the user who will own the database, or
DEFAULTto use the default (namely, the user executing the command). To create a database owned by another role or to change the owner of an existing database, you must be a direct or indirect member of the specified role, or the username in the provider is a superuser. - tablespace
Name String - The name of the tablespace that will be
associated with the database, or
DEFAULTto use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. - template String
- The name of the template database from which to create
the database, or
DEFAULTto use the default template (template0). NOTE: the default in Terraform istemplate0, nottemplate1. Changing this value will force the creation of a new resource as this value can only be changed when a database is created.
Outputs
All input properties are implicitly available as output properties. Additionally, the Database resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing Database Resource
Get an existing Database 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?: DatabaseState, opts?: CustomResourceOptions): Database@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
allow_connections: Optional[bool] = None,
alter_object_ownership: Optional[bool] = None,
connection_limit: Optional[int] = None,
encoding: Optional[str] = None,
is_template: Optional[bool] = None,
lc_collate: Optional[str] = None,
lc_ctype: Optional[str] = None,
name: Optional[str] = None,
owner: Optional[str] = None,
tablespace_name: Optional[str] = None,
template: Optional[str] = None) -> Databasefunc GetDatabase(ctx *Context, name string, id IDInput, state *DatabaseState, opts ...ResourceOption) (*Database, error)public static Database Get(string name, Input<string> id, DatabaseState? state, CustomResourceOptions? opts = null)public static Database get(String name, Output<String> id, DatabaseState state, CustomResourceOptions options)resources: _: type: postgresql:Database get: id: ${id}- 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.
- 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.
- Allow
Connections bool - If
falsethen no one can connect to this database. The default istrue, allowing connections (except as restricted by other mechanisms, such asGRANTorREVOKE CONNECT). - Alter
Object boolOwnership - If
true, the change of the databaseownerwill also include a reassignment of the ownership of preexisting objects like tables or sequences from the previous owner to the new one. If set tofalse(the default), then the previous databaseownerwill still hold the ownership of the objects in that database. To alter existing objects in the database, you must be a direct or indirect member of the specified role, or the username in the provider must be superuser. - Connection
Limit int - How many concurrent connections can be
established to this database.
-1(the default) means no limit. - Encoding string
- Character set encoding to use in the database.
Specify a string constant (e.g.
UTF8orSQL_ASCII), or an integer encoding number. If unset or set to an empty string the default encoding is set toUTF8. If set toDEFAULTTerraform will use the same encoding as the template database. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - Is
Template bool - If
true, then this database can be cloned by any user withCREATEDBprivileges; iffalse(the default), then only superusers or the owner of the database can clone it. - Lc
Collate string - Collation order (
LC_COLLATE) to use in the database. This affects the sort order applied to strings, e.g. in queries withORDER BY, as well as the order used in indexes on text columns. If unset or set to an empty string the default collation is set toC. If set toDEFAULTTerraform will use the same collation order as the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - Lc
Ctype string - Character classification (
LC_CTYPE) to use in the database. This affects the categorization of characters, e.g. lower, upper and digit. If unset or set to an empty string the default character classification is set toC. If set toDEFAULTTerraform will use the character classification of the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - Name string
- The name of the database. Must be unique on the PostgreSQL server instance where it is configured.
- Owner string
- The role name of the user who will own the database, or
DEFAULTto use the default (namely, the user executing the command). To create a database owned by another role or to change the owner of an existing database, you must be a direct or indirect member of the specified role, or the username in the provider is a superuser. - Tablespace
Name string - The name of the tablespace that will be
associated with the database, or
DEFAULTto use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. - Template string
- The name of the template database from which to create
the database, or
DEFAULTto use the default template (template0). NOTE: the default in Terraform istemplate0, nottemplate1. Changing this value will force the creation of a new resource as this value can only be changed when a database is created.
- Allow
Connections bool - If
falsethen no one can connect to this database. The default istrue, allowing connections (except as restricted by other mechanisms, such asGRANTorREVOKE CONNECT). - Alter
Object boolOwnership - If
true, the change of the databaseownerwill also include a reassignment of the ownership of preexisting objects like tables or sequences from the previous owner to the new one. If set tofalse(the default), then the previous databaseownerwill still hold the ownership of the objects in that database. To alter existing objects in the database, you must be a direct or indirect member of the specified role, or the username in the provider must be superuser. - Connection
Limit int - How many concurrent connections can be
established to this database.
-1(the default) means no limit. - Encoding string
- Character set encoding to use in the database.
Specify a string constant (e.g.
UTF8orSQL_ASCII), or an integer encoding number. If unset or set to an empty string the default encoding is set toUTF8. If set toDEFAULTTerraform will use the same encoding as the template database. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - Is
Template bool - If
true, then this database can be cloned by any user withCREATEDBprivileges; iffalse(the default), then only superusers or the owner of the database can clone it. - Lc
Collate string - Collation order (
LC_COLLATE) to use in the database. This affects the sort order applied to strings, e.g. in queries withORDER BY, as well as the order used in indexes on text columns. If unset or set to an empty string the default collation is set toC. If set toDEFAULTTerraform will use the same collation order as the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - Lc
Ctype string - Character classification (
LC_CTYPE) to use in the database. This affects the categorization of characters, e.g. lower, upper and digit. If unset or set to an empty string the default character classification is set toC. If set toDEFAULTTerraform will use the character classification of the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - Name string
- The name of the database. Must be unique on the PostgreSQL server instance where it is configured.
- Owner string
- The role name of the user who will own the database, or
DEFAULTto use the default (namely, the user executing the command). To create a database owned by another role or to change the owner of an existing database, you must be a direct or indirect member of the specified role, or the username in the provider is a superuser. - Tablespace
Name string - The name of the tablespace that will be
associated with the database, or
DEFAULTto use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. - Template string
- The name of the template database from which to create
the database, or
DEFAULTto use the default template (template0). NOTE: the default in Terraform istemplate0, nottemplate1. Changing this value will force the creation of a new resource as this value can only be changed when a database is created.
- allow
Connections Boolean - If
falsethen no one can connect to this database. The default istrue, allowing connections (except as restricted by other mechanisms, such asGRANTorREVOKE CONNECT). - alter
Object BooleanOwnership - If
true, the change of the databaseownerwill also include a reassignment of the ownership of preexisting objects like tables or sequences from the previous owner to the new one. If set tofalse(the default), then the previous databaseownerwill still hold the ownership of the objects in that database. To alter existing objects in the database, you must be a direct or indirect member of the specified role, or the username in the provider must be superuser. - connection
Limit Integer - How many concurrent connections can be
established to this database.
-1(the default) means no limit. - encoding String
- Character set encoding to use in the database.
Specify a string constant (e.g.
UTF8orSQL_ASCII), or an integer encoding number. If unset or set to an empty string the default encoding is set toUTF8. If set toDEFAULTTerraform will use the same encoding as the template database. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - is
Template Boolean - If
true, then this database can be cloned by any user withCREATEDBprivileges; iffalse(the default), then only superusers or the owner of the database can clone it. - lc
Collate String - Collation order (
LC_COLLATE) to use in the database. This affects the sort order applied to strings, e.g. in queries withORDER BY, as well as the order used in indexes on text columns. If unset or set to an empty string the default collation is set toC. If set toDEFAULTTerraform will use the same collation order as the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - lc
Ctype String - Character classification (
LC_CTYPE) to use in the database. This affects the categorization of characters, e.g. lower, upper and digit. If unset or set to an empty string the default character classification is set toC. If set toDEFAULTTerraform will use the character classification of the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - name String
- The name of the database. Must be unique on the PostgreSQL server instance where it is configured.
- owner String
- The role name of the user who will own the database, or
DEFAULTto use the default (namely, the user executing the command). To create a database owned by another role or to change the owner of an existing database, you must be a direct or indirect member of the specified role, or the username in the provider is a superuser. - tablespace
Name String - The name of the tablespace that will be
associated with the database, or
DEFAULTto use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. - template String
- The name of the template database from which to create
the database, or
DEFAULTto use the default template (template0). NOTE: the default in Terraform istemplate0, nottemplate1. Changing this value will force the creation of a new resource as this value can only be changed when a database is created.
- allow
Connections boolean - If
falsethen no one can connect to this database. The default istrue, allowing connections (except as restricted by other mechanisms, such asGRANTorREVOKE CONNECT). - alter
Object booleanOwnership - If
true, the change of the databaseownerwill also include a reassignment of the ownership of preexisting objects like tables or sequences from the previous owner to the new one. If set tofalse(the default), then the previous databaseownerwill still hold the ownership of the objects in that database. To alter existing objects in the database, you must be a direct or indirect member of the specified role, or the username in the provider must be superuser. - connection
Limit number - How many concurrent connections can be
established to this database.
-1(the default) means no limit. - encoding string
- Character set encoding to use in the database.
Specify a string constant (e.g.
UTF8orSQL_ASCII), or an integer encoding number. If unset or set to an empty string the default encoding is set toUTF8. If set toDEFAULTTerraform will use the same encoding as the template database. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - is
Template boolean - If
true, then this database can be cloned by any user withCREATEDBprivileges; iffalse(the default), then only superusers or the owner of the database can clone it. - lc
Collate string - Collation order (
LC_COLLATE) to use in the database. This affects the sort order applied to strings, e.g. in queries withORDER BY, as well as the order used in indexes on text columns. If unset or set to an empty string the default collation is set toC. If set toDEFAULTTerraform will use the same collation order as the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - lc
Ctype string - Character classification (
LC_CTYPE) to use in the database. This affects the categorization of characters, e.g. lower, upper and digit. If unset or set to an empty string the default character classification is set toC. If set toDEFAULTTerraform will use the character classification of the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - name string
- The name of the database. Must be unique on the PostgreSQL server instance where it is configured.
- owner string
- The role name of the user who will own the database, or
DEFAULTto use the default (namely, the user executing the command). To create a database owned by another role or to change the owner of an existing database, you must be a direct or indirect member of the specified role, or the username in the provider is a superuser. - tablespace
Name string - The name of the tablespace that will be
associated with the database, or
DEFAULTto use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. - template string
- The name of the template database from which to create
the database, or
DEFAULTto use the default template (template0). NOTE: the default in Terraform istemplate0, nottemplate1. Changing this value will force the creation of a new resource as this value can only be changed when a database is created.
- allow_
connections bool - If
falsethen no one can connect to this database. The default istrue, allowing connections (except as restricted by other mechanisms, such asGRANTorREVOKE CONNECT). - alter_
object_ boolownership - If
true, the change of the databaseownerwill also include a reassignment of the ownership of preexisting objects like tables or sequences from the previous owner to the new one. If set tofalse(the default), then the previous databaseownerwill still hold the ownership of the objects in that database. To alter existing objects in the database, you must be a direct or indirect member of the specified role, or the username in the provider must be superuser. - connection_
limit int - How many concurrent connections can be
established to this database.
-1(the default) means no limit. - encoding str
- Character set encoding to use in the database.
Specify a string constant (e.g.
UTF8orSQL_ASCII), or an integer encoding number. If unset or set to an empty string the default encoding is set toUTF8. If set toDEFAULTTerraform will use the same encoding as the template database. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - is_
template bool - If
true, then this database can be cloned by any user withCREATEDBprivileges; iffalse(the default), then only superusers or the owner of the database can clone it. - lc_
collate str - Collation order (
LC_COLLATE) to use in the database. This affects the sort order applied to strings, e.g. in queries withORDER BY, as well as the order used in indexes on text columns. If unset or set to an empty string the default collation is set toC. If set toDEFAULTTerraform will use the same collation order as the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - lc_
ctype str - Character classification (
LC_CTYPE) to use in the database. This affects the categorization of characters, e.g. lower, upper and digit. If unset or set to an empty string the default character classification is set toC. If set toDEFAULTTerraform will use the character classification of the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - name str
- The name of the database. Must be unique on the PostgreSQL server instance where it is configured.
- owner str
- The role name of the user who will own the database, or
DEFAULTto use the default (namely, the user executing the command). To create a database owned by another role or to change the owner of an existing database, you must be a direct or indirect member of the specified role, or the username in the provider is a superuser. - tablespace_
name str - The name of the tablespace that will be
associated with the database, or
DEFAULTto use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. - template str
- The name of the template database from which to create
the database, or
DEFAULTto use the default template (template0). NOTE: the default in Terraform istemplate0, nottemplate1. Changing this value will force the creation of a new resource as this value can only be changed when a database is created.
- allow
Connections Boolean - If
falsethen no one can connect to this database. The default istrue, allowing connections (except as restricted by other mechanisms, such asGRANTorREVOKE CONNECT). - alter
Object BooleanOwnership - If
true, the change of the databaseownerwill also include a reassignment of the ownership of preexisting objects like tables or sequences from the previous owner to the new one. If set tofalse(the default), then the previous databaseownerwill still hold the ownership of the objects in that database. To alter existing objects in the database, you must be a direct or indirect member of the specified role, or the username in the provider must be superuser. - connection
Limit Number - How many concurrent connections can be
established to this database.
-1(the default) means no limit. - encoding String
- Character set encoding to use in the database.
Specify a string constant (e.g.
UTF8orSQL_ASCII), or an integer encoding number. If unset or set to an empty string the default encoding is set toUTF8. If set toDEFAULTTerraform will use the same encoding as the template database. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - is
Template Boolean - If
true, then this database can be cloned by any user withCREATEDBprivileges; iffalse(the default), then only superusers or the owner of the database can clone it. - lc
Collate String - Collation order (
LC_COLLATE) to use in the database. This affects the sort order applied to strings, e.g. in queries withORDER BY, as well as the order used in indexes on text columns. If unset or set to an empty string the default collation is set toC. If set toDEFAULTTerraform will use the same collation order as the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - lc
Ctype String - Character classification (
LC_CTYPE) to use in the database. This affects the categorization of characters, e.g. lower, upper and digit. If unset or set to an empty string the default character classification is set toC. If set toDEFAULTTerraform will use the character classification of the specifiedtemplatedatabase. Changing this value will force the creation of a new resource as this value can only be changed when a database is created. - name String
- The name of the database. Must be unique on the PostgreSQL server instance where it is configured.
- owner String
- The role name of the user who will own the database, or
DEFAULTto use the default (namely, the user executing the command). To create a database owned by another role or to change the owner of an existing database, you must be a direct or indirect member of the specified role, or the username in the provider is a superuser. - tablespace
Name String - The name of the tablespace that will be
associated with the database, or
DEFAULTto use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. - template String
- The name of the template database from which to create
the database, or
DEFAULTto use the default template (template0). NOTE: the default in Terraform istemplate0, nottemplate1. Changing this value will force the creation of a new resource as this value can only be changed when a database is created.
Import
Example
postgresql.Database supports importing resources. Supposing the following
Terraform:
import * as pulumi from "@pulumi/pulumi";
import * as postgresql from "@pulumi/postgresql";
const db1 = new postgresql.Database("db1", {name: "testdb1"});
import pulumi
import pulumi_postgresql as postgresql
db1 = postgresql.Database("db1", name="testdb1")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using PostgreSql = Pulumi.PostgreSql;
return await Deployment.RunAsync(() =>
{
var db1 = new PostgreSql.Index.Database("db1", new()
{
Name = "testdb1",
});
});
package main
import (
"github.com/pulumi/pulumi-postgresql/sdk/v3/go/postgresql"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := postgresql.NewDatabase(ctx, "db1", &postgresql.DatabaseArgs{
Name: pulumi.String("testdb1"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.postgresql.Database;
import com.pulumi.postgresql.DatabaseArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var db1 = new Database("db1", DatabaseArgs.builder()
.name("testdb1")
.build());
}
}
resources:
db1:
type: postgresql:Database
properties:
name: testdb1
It is possible to import a postgresql.Database resource with the following
command:
$ terraform import postgresql_database.db1 testdb1
Where testdb1 is the name of the database to import and
postgresql_database.db1 is the name of the resource whose state will be
populated as a result of the command.
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- PostgreSQL pulumi/pulumi-postgresql
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
postgresqlTerraform Provider.
published on Friday, Apr 10, 2026 by Pulumi
