Skip to content

Commit ea58e50

Browse files
authored
fix: only trigger the pgbouncer healthcheck when the database changes (#229)
resolves #228
1 parent f789c93 commit ea58e50

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/database/PgBouncer.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ export interface PgBouncerProps {
6060
* EC2 instance options
6161
*/
6262
instanceProps?: Partial<ec2.InstanceProps>;
63+
64+
/**
65+
* Optional reference to the database bootstrapper CustomResource.
66+
* When provided, the health check will re-trigger if the database setup changes.
67+
*/
68+
databaseBootstrapper?: CustomResource;
6369
}
6470

6571
export class PgBouncer extends Construct {
@@ -255,8 +261,10 @@ export class PgBouncer extends Construct {
255261
serviceToken: healthCheckFunction.functionArn,
256262
properties: {
257263
InstanceId: this.instance.instanceId,
258-
// Add timestamp to force re-execution on stack updates
259-
Timestamp: new Date().toISOString(),
264+
// Reference the database bootstrapper to re-trigger on database changes
265+
...(props.databaseBootstrapper && {
266+
DatabaseBootstrapperRef: props.databaseBootstrapper.ref,
267+
}),
260268
},
261269
});
262270

lib/database/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ export class PgStacDatabase extends Construct {
276276
reservePoolSize: 5,
277277
reservePoolTimeout: 5,
278278
},
279+
databaseBootstrapper: bootstrapper,
279280
});
280281

281282
this._pgBouncerServer.node.addDependency(bootstrapper);

0 commit comments

Comments
 (0)