Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/database/PgBouncer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ export interface PgBouncerProps {
* EC2 instance options
*/
instanceProps?: Partial<ec2.InstanceProps>;

/**
* Optional reference to the database bootstrapper CustomResource.
* When provided, the health check will re-trigger if the database setup changes.
*/
databaseBootstrapper?: CustomResource;
}

export class PgBouncer extends Construct {
Expand Down Expand Up @@ -255,8 +261,10 @@ export class PgBouncer extends Construct {
serviceToken: healthCheckFunction.functionArn,
properties: {
InstanceId: this.instance.instanceId,
// Add timestamp to force re-execution on stack updates
Timestamp: new Date().toISOString(),
// Reference the database bootstrapper to re-trigger on database changes
...(props.databaseBootstrapper && {
DatabaseBootstrapperRef: props.databaseBootstrapper.ref,
}),
},
});

Expand Down
1 change: 1 addition & 0 deletions lib/database/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export class PgStacDatabase extends Construct {
reservePoolSize: 5,
reservePoolTimeout: 5,
},
databaseBootstrapper: bootstrapper,
});

this._pgBouncerServer.node.addDependency(bootstrapper);
Expand Down
Loading