Skip to content

feat: add a ReplicationSlot custom resource - #21

Open
pascal-botpress wants to merge 1 commit into
masterfrom
pb/rds-replication
Open

feat: add a ReplicationSlot custom resource#21
pascal-botpress wants to merge 1 commit into
masterfrom
pb/rds-replication

Conversation

@pascal-botpress

@pascal-botpress pascal-botpress commented Aug 28, 2026

Copy link
Copy Markdown
Member

Contributes to KKN-927.

Copilot AI lite review requested due to automatic review settings August 28, 2026 16:21
@pascal-botpress
pascal-botpress marked this pull request as draft August 28, 2026 16:21
@greptile-apps

greptile-apps Bot commented Aug 28, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds a public ReplicationSlot CDK construct and wires its CloudFormation lifecycle through the shared provider to PostgreSQL.

  • Creates or safely adopts logical replication slots after validating the database, plugin, and optional required publication.
  • Records creation provenance in the physical resource ID so adopted slots are preserved during deletion.
  • Adds database-scoped slot deletion and integration coverage for creation, updates, adoption, and cleanup.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
cdk-postgresql/lib/replication-slot.handler.ts Implements validated replication-slot create, update, adoption, provenance tracking, and deletion lifecycle behavior.
cdk-postgresql/lib/replication-slot.ts Exposes the replication-slot construct with plugin, publication, provider, and removal-policy configuration.
cdk-postgresql/lib/postgres.ts Adds parameterized logical-slot creation and database-scoped deletion operations.
cdk-postgresql/lib/handler.ts Routes the new replication-slot custom-resource type to its specialized handler.
cdk-postgresql/test/lambda.integration.test.ts Adds broad integration coverage for slot creation, validation, replacement signaling, adoption, and deletion.

Sequence Diagram

sequenceDiagram
    participant Stack as CDK Stack
    participant CFN as CloudFormation
    participant Lambda as Provider Lambda
    participant Handler as ReplicationSlot Handler
    participant PG as PostgreSQL
    Stack->>CFN: Declare ReplicationSlot
    CFN->>Lambda: Create / Update / Delete
    Lambda->>Handler: Dispatch custom-resource event
    Handler->>PG: Check publication and existing slot
    alt Slot absent
        Handler->>PG: Create logical replication slot
        Handler-->>CFN: Physical ID with created provenance
    else Compatible slot exists
        Handler-->>CFN: Physical ID with adopted provenance
    end
    opt Delete created slot
        Handler->>PG: Drop slot in connected database
    end
Loading

Reviews (5): Last reviewed commit: "feat: add a ReplicationSlot custom resou..." | Re-trigger Greptile

Comment thread cdk-postgresql/lib/replication-slot.handler.ts Outdated
Comment thread cdk-postgresql/lib/replication-slot.handler.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for managing PostgreSQL logical replication slots via a new CDK ReplicationSlot construct backed by the provider Lambda’s custom-resource handler, along with integration tests to validate slot lifecycle behavior.

Changes:

  • Introduces ReplicationSlot construct (Custom::Postgresql-ReplicationSlot) and wires it into the provider Lambda dispatcher.
  • Adds Lambda-side replication slot create/drop operations and publication precondition validation.
  • Extends integration tests (and helpers) to cover replication slot behavior; bumps package version to 3.1.0.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cdk-postgresql/test/lambda.integration.test.ts Adds integration tests for the replication-slot custom resource and configures Postgres with wal_level=logical.
cdk-postgresql/test/helpers.ts Adds a helper to check for replication slot existence in tests.
cdk-postgresql/package.json Version bump for new feature release.
cdk-postgresql/lib/replication-slot.ts New CDK construct wrapping a CustomResource for replication slots.
cdk-postgresql/lib/replication-slot.handler.ts New custom-resource Lambda handler implementing Create/Update/Delete logic for replication slots.
cdk-postgresql/lib/postgres.ts Adds SQL helpers for creating/dropping logical replication slots.
cdk-postgresql/lib/index.ts Exports the new construct from the public library surface.
cdk-postgresql/lib/handler.ts Routes the new Custom::Postgresql-ReplicationSlot resource type to the new handler.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cdk-postgresql/lib/replication-slot.handler.ts
Comment thread cdk-postgresql/test/helpers.ts
Comment thread cdk-postgresql/lib/replication-slot.handler.ts
@linear-code

linear-code Bot commented Aug 28, 2026

Copy link
Copy Markdown

KKN-927

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread cdk-postgresql/lib/replication-slot.handler.ts
Comment thread cdk-postgresql/lib/replication-slot.handler.ts
@pascal-botpress
pascal-botpress marked this pull request as ready for review August 28, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants