feat: add a ReplicationSlot custom resource - #21
Conversation
Greptile SummaryThe PR adds a public
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| 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
Reviews (5): Last reviewed commit: "feat: add a ReplicationSlot custom resou..." | Re-trigger Greptile
There was a problem hiding this comment.
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
ReplicationSlotconstruct (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.
3c26593 to
26baa67
Compare
8f261ec to
26baa67
Compare
Contributes to KKN-927.