1. Packages
  2. Postgresql Provider
  3. API Docs
  4. Subscription
PostgreSQL v3.15.1 published on Saturday, Mar 15, 2025 by Pulumi

postgresql.Subscription

Explore with Pulumi AI

The postgresql.Subscription resource creates and manages a publication on a PostgreSQL server.

Usage

import * as pulumi from "@pulumi/pulumi";
import * as postgresql from "@pulumi/postgresql";

const subscription = new postgresql.Subscription("subscription", {
    name: "subscription",
    conninfo: "host=localhost port=5432 dbname=mydb user=postgres password=postgres",
    publications: ["publication"],
});
Copy
import pulumi
import pulumi_postgresql as postgresql

subscription = postgresql.Subscription("subscription",
    name="subscription",
    conninfo="host=localhost port=5432 dbname=mydb user=postgres password=postgres",
    publications=["publication"])
Copy
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.NewSubscription(ctx, "subscription", &postgresql.SubscriptionArgs{
			Name:     pulumi.String("subscription"),
			Conninfo: pulumi.String("host=localhost port=5432 dbname=mydb user=postgres password=postgres"),
			Publications: pulumi.StringArray{
				pulumi.String("publication"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using PostgreSql = Pulumi.PostgreSql;

return await Deployment.RunAsync(() => 
{
    var subscription = new PostgreSql.Subscription("subscription", new()
    {
        Name = "subscription",
        Conninfo = "host=localhost port=5432 dbname=mydb user=postgres password=postgres",
        Publications = new[]
        {
            "publication",
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.postgresql.Subscription;
import com.pulumi.postgresql.SubscriptionArgs;
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 subscription = new Subscription("subscription", SubscriptionArgs.builder()
            .name("subscription")
            .conninfo("host=localhost port=5432 dbname=mydb user=postgres password=postgres")
            .publications("publication")
            .build());

    }
}
Copy
resources:
  subscription:
    type: postgresql:Subscription
    properties:
      name: subscription
      conninfo: host=localhost port=5432 dbname=mydb user=postgres password=postgres
      publications:
        - publication
Copy

Postgres documentation

  • https://www.postgresql.org/docs/current/sql-createsubscription.html

Create Subscription Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Subscription(name: string, args: SubscriptionArgs, opts?: CustomResourceOptions);
@overload
def Subscription(resource_name: str,
                 args: SubscriptionArgs,
                 opts: Optional[ResourceOptions] = None)

@overload
def Subscription(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 conninfo: Optional[str] = None,
                 publications: Optional[Sequence[str]] = None,
                 create_slot: Optional[bool] = None,
                 database: Optional[str] = None,
                 name: Optional[str] = None,
                 slot_name: Optional[str] = None)
func NewSubscription(ctx *Context, name string, args SubscriptionArgs, opts ...ResourceOption) (*Subscription, error)
public Subscription(string name, SubscriptionArgs args, CustomResourceOptions? opts = null)
public Subscription(String name, SubscriptionArgs args)
public Subscription(String name, SubscriptionArgs args, CustomResourceOptions options)
type: postgresql:Subscription
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. SubscriptionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. SubscriptionArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. SubscriptionArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. SubscriptionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. SubscriptionArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var subscriptionResource = new PostgreSql.Subscription("subscriptionResource", new()
{
    Conninfo = "string",
    Publications = new[]
    {
        "string",
    },
    CreateSlot = false,
    Database = "string",
    Name = "string",
    SlotName = "string",
});
Copy
example, err := postgresql.NewSubscription(ctx, "subscriptionResource", &postgresql.SubscriptionArgs{
	Conninfo: pulumi.String("string"),
	Publications: pulumi.StringArray{
		pulumi.String("string"),
	},
	CreateSlot: pulumi.Bool(false),
	Database:   pulumi.String("string"),
	Name:       pulumi.String("string"),
	SlotName:   pulumi.String("string"),
})
Copy
var subscriptionResource = new Subscription("subscriptionResource", SubscriptionArgs.builder()
    .conninfo("string")
    .publications("string")
    .createSlot(false)
    .database("string")
    .name("string")
    .slotName("string")
    .build());
Copy
subscription_resource = postgresql.Subscription("subscriptionResource",
    conninfo="string",
    publications=["string"],
    create_slot=False,
    database="string",
    name="string",
    slot_name="string")
Copy
const subscriptionResource = new postgresql.Subscription("subscriptionResource", {
    conninfo: "string",
    publications: ["string"],
    createSlot: false,
    database: "string",
    name: "string",
    slotName: "string",
});
Copy
type: postgresql:Subscription
properties:
    conninfo: string
    createSlot: false
    database: string
    name: string
    publications:
        - string
    slotName: string
Copy

Subscription 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 Subscription resource accepts the following input properties:

Conninfo
This property is required.
Changes to this property will trigger replacement.
string
The connection string to the publisher. It should follow the keyword/value format
Publications
This property is required.
Changes to this property will trigger replacement.
List<string>
Names of the publications on the publisher to subscribe to
CreateSlot Changes to this property will trigger replacement. bool
Specifies whether the command should create the replication slot on the publisher. Default behavior is true
Database Changes to this property will trigger replacement. string
Which database to create the subscription on. Defaults to provider database.
Name Changes to this property will trigger replacement. string
The name of the publication.
SlotName Changes to this property will trigger replacement. string
Name of the replication slot to use. The default behavior is to use the name of the subscription for the slot name
Conninfo
This property is required.
Changes to this property will trigger replacement.
string
The connection string to the publisher. It should follow the keyword/value format
Publications
This property is required.
Changes to this property will trigger replacement.
[]string
Names of the publications on the publisher to subscribe to
CreateSlot Changes to this property will trigger replacement. bool
Specifies whether the command should create the replication slot on the publisher. Default behavior is true
Database Changes to this property will trigger replacement. string
Which database to create the subscription on. Defaults to provider database.
Name Changes to this property will trigger replacement. string
The name of the publication.
SlotName Changes to this property will trigger replacement. string
Name of the replication slot to use. The default behavior is to use the name of the subscription for the slot name
conninfo
This property is required.
Changes to this property will trigger replacement.
String
The connection string to the publisher. It should follow the keyword/value format
publications
This property is required.
Changes to this property will trigger replacement.
List<String>
Names of the publications on the publisher to subscribe to
createSlot Changes to this property will trigger replacement. Boolean
Specifies whether the command should create the replication slot on the publisher. Default behavior is true
database Changes to this property will trigger replacement. String
Which database to create the subscription on. Defaults to provider database.
name Changes to this property will trigger replacement. String
The name of the publication.
slotName Changes to this property will trigger replacement. String
Name of the replication slot to use. The default behavior is to use the name of the subscription for the slot name
conninfo
This property is required.
Changes to this property will trigger replacement.
string
The connection string to the publisher. It should follow the keyword/value format
publications
This property is required.
Changes to this property will trigger replacement.
string[]
Names of the publications on the publisher to subscribe to
createSlot Changes to this property will trigger replacement. boolean
Specifies whether the command should create the replication slot on the publisher. Default behavior is true
database Changes to this property will trigger replacement. string
Which database to create the subscription on. Defaults to provider database.
name Changes to this property will trigger replacement. string
The name of the publication.
slotName Changes to this property will trigger replacement. string
Name of the replication slot to use. The default behavior is to use the name of the subscription for the slot name
conninfo
This property is required.
Changes to this property will trigger replacement.
str
The connection string to the publisher. It should follow the keyword/value format
publications
This property is required.
Changes to this property will trigger replacement.
Sequence[str]
Names of the publications on the publisher to subscribe to
create_slot Changes to this property will trigger replacement. bool
Specifies whether the command should create the replication slot on the publisher. Default behavior is true
database Changes to this property will trigger replacement. str
Which database to create the subscription on. Defaults to provider database.
name Changes to this property will trigger replacement. str
The name of the publication.
slot_name Changes to this property will trigger replacement. str
Name of the replication slot to use. The default behavior is to use the name of the subscription for the slot name
conninfo
This property is required.
Changes to this property will trigger replacement.
String
The connection string to the publisher. It should follow the keyword/value format
publications
This property is required.
Changes to this property will trigger replacement.
List<String>
Names of the publications on the publisher to subscribe to
createSlot Changes to this property will trigger replacement. Boolean
Specifies whether the command should create the replication slot on the publisher. Default behavior is true
database Changes to this property will trigger replacement. String
Which database to create the subscription on. Defaults to provider database.
name Changes to this property will trigger replacement. String
The name of the publication.
slotName Changes to this property will trigger replacement. String
Name of the replication slot to use. The default behavior is to use the name of the subscription for the slot name

Outputs

All input properties are implicitly available as output properties. Additionally, the Subscription 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 Subscription Resource

Get an existing Subscription 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?: SubscriptionState, opts?: CustomResourceOptions): Subscription
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        conninfo: Optional[str] = None,
        create_slot: Optional[bool] = None,
        database: Optional[str] = None,
        name: Optional[str] = None,
        publications: Optional[Sequence[str]] = None,
        slot_name: Optional[str] = None) -> Subscription
func GetSubscription(ctx *Context, name string, id IDInput, state *SubscriptionState, opts ...ResourceOption) (*Subscription, error)
public static Subscription Get(string name, Input<string> id, SubscriptionState? state, CustomResourceOptions? opts = null)
public static Subscription get(String name, Output<String> id, SubscriptionState state, CustomResourceOptions options)
resources:  _:    type: postgresql:Subscription    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
Conninfo Changes to this property will trigger replacement. string
The connection string to the publisher. It should follow the keyword/value format
CreateSlot Changes to this property will trigger replacement. bool
Specifies whether the command should create the replication slot on the publisher. Default behavior is true
Database Changes to this property will trigger replacement. string
Which database to create the subscription on. Defaults to provider database.
Name Changes to this property will trigger replacement. string
The name of the publication.
Publications Changes to this property will trigger replacement. List<string>
Names of the publications on the publisher to subscribe to
SlotName Changes to this property will trigger replacement. string
Name of the replication slot to use. The default behavior is to use the name of the subscription for the slot name
Conninfo Changes to this property will trigger replacement. string
The connection string to the publisher. It should follow the keyword/value format
CreateSlot Changes to this property will trigger replacement. bool
Specifies whether the command should create the replication slot on the publisher. Default behavior is true
Database Changes to this property will trigger replacement. string
Which database to create the subscription on. Defaults to provider database.
Name Changes to this property will trigger replacement. string
The name of the publication.
Publications Changes to this property will trigger replacement. []string
Names of the publications on the publisher to subscribe to
SlotName Changes to this property will trigger replacement. string
Name of the replication slot to use. The default behavior is to use the name of the subscription for the slot name
conninfo Changes to this property will trigger replacement. String
The connection string to the publisher. It should follow the keyword/value format
createSlot Changes to this property will trigger replacement. Boolean
Specifies whether the command should create the replication slot on the publisher. Default behavior is true
database Changes to this property will trigger replacement. String
Which database to create the subscription on. Defaults to provider database.
name Changes to this property will trigger replacement. String
The name of the publication.
publications Changes to this property will trigger replacement. List<String>
Names of the publications on the publisher to subscribe to
slotName Changes to this property will trigger replacement. String
Name of the replication slot to use. The default behavior is to use the name of the subscription for the slot name
conninfo Changes to this property will trigger replacement. string
The connection string to the publisher. It should follow the keyword/value format
createSlot Changes to this property will trigger replacement. boolean
Specifies whether the command should create the replication slot on the publisher. Default behavior is true
database Changes to this property will trigger replacement. string
Which database to create the subscription on. Defaults to provider database.
name Changes to this property will trigger replacement. string
The name of the publication.
publications Changes to this property will trigger replacement. string[]
Names of the publications on the publisher to subscribe to
slotName Changes to this property will trigger replacement. string
Name of the replication slot to use. The default behavior is to use the name of the subscription for the slot name
conninfo Changes to this property will trigger replacement. str
The connection string to the publisher. It should follow the keyword/value format
create_slot Changes to this property will trigger replacement. bool
Specifies whether the command should create the replication slot on the publisher. Default behavior is true
database Changes to this property will trigger replacement. str
Which database to create the subscription on. Defaults to provider database.
name Changes to this property will trigger replacement. str
The name of the publication.
publications Changes to this property will trigger replacement. Sequence[str]
Names of the publications on the publisher to subscribe to
slot_name Changes to this property will trigger replacement. str
Name of the replication slot to use. The default behavior is to use the name of the subscription for the slot name
conninfo Changes to this property will trigger replacement. String
The connection string to the publisher. It should follow the keyword/value format
createSlot Changes to this property will trigger replacement. Boolean
Specifies whether the command should create the replication slot on the publisher. Default behavior is true
database Changes to this property will trigger replacement. String
Which database to create the subscription on. Defaults to provider database.
name Changes to this property will trigger replacement. String
The name of the publication.
publications Changes to this property will trigger replacement. List<String>
Names of the publications on the publisher to subscribe to
slotName Changes to this property will trigger replacement. String
Name of the replication slot to use. The default behavior is to use the name of the subscription for the slot name

Package Details

Repository
PostgreSQL pulumi/pulumi-postgresql
License
Apache-2.0
Notes
This Pulumi package is based on the postgresql Terraform Provider.