diff --git a/lib/database/PgBouncer.ts b/lib/database/PgBouncer.ts index f531c09..e8aae92 100644 --- a/lib/database/PgBouncer.ts +++ b/lib/database/PgBouncer.ts @@ -60,6 +60,12 @@ export interface PgBouncerProps { * EC2 instance options */ instanceProps?: Partial; + + /** + * 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 { @@ -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, + }), }, }); diff --git a/lib/database/index.ts b/lib/database/index.ts index 7e967b6..834312b 100644 --- a/lib/database/index.ts +++ b/lib/database/index.ts @@ -276,6 +276,7 @@ export class PgStacDatabase extends Construct { reservePoolSize: 5, reservePoolTimeout: 5, }, + databaseBootstrapper: bootstrapper, }); this._pgBouncerServer.node.addDependency(bootstrapper);