Skip to content

Unable to create replication slot on AWS RDS Replica Instance #537

@MickSheppardCorvus

Description

@MickSheppardCorvus

Terraform Version

Terraform 1.3
cyrilgdn/postgresql 1.25.0

Affected Resource(s)

  • postgresql_publication_slot

Terraform Configuration Files

provider "postgresql" {
  host      = "my-rds-database-replica.us-east-1.rds.amazonaws.com"
  port      = "5432"
  username  = "mydbuser"
  password  = <>
  database  = "mydb"
  superuser = false

  alias = "my_rds_database_replica"
}

resource "postgresql_replication_slot" "my_logical_slot" {
  provider = postgresql.my_rds_database_replica

  name     = "my_logical_slot"
  database = "mydb"
  plugin   = "pgoutput"
}

Debug Output

n/a

Panic Output

n/a

Expected Behaviour

A logical replication slot should have been created on the RDS replica database

Actual Behaviour

Error: could not start transaction: pq: cannot set transaction read-write mode during recovery

Step To Reproduce

  1. Create an RDS PostgreSQL database with running version 16.x or later with rds.logical_replication=1 in the parameter set.
  2. Create an RDS Replica database from the second database with the same configuration
  3. Configure the Terraform with the hostname from the replica
  4. terraform plan

Important Factoids

PostgreSQL supports logical replication slots being created on replica in recovery mode from version 16.

Creating the replication slot manually on the database from a psql command line using the command SELECT FROM pg_create_logical_replication_slot("my_logical_slot","pgoutput"); works. The issue appears to be with the database/sql package attempting to switch the connection into read-write mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions