@@ -39,6 +39,7 @@ export class PgStacDatabase extends Construct {
3939
4040 public readonly connectionTarget : rds . IDatabaseInstance | ec2 . Instance ;
4141 public readonly securityGroup ?: ec2 . SecurityGroup ;
42+ public readonly secretBootstrapper ?: CustomResource ;
4243
4344 constructor ( scope : Construct , id : string , props : PgStacDatabaseProps ) {
4445 super ( scope , id ) ;
@@ -79,7 +80,7 @@ export class PgStacDatabase extends Construct {
7980 code : aws_lambda . Code . fromDockerBuild ( __dirname , {
8081 file : "bootstrapper_runtime/Dockerfile" ,
8182 buildArgs : {
82- PYTHON_VERSION : "3.11"
83+ PYTHON_VERSION : "3.11" ,
8384 } ,
8485 } ) ,
8586 vpc : hasVpc ( this . db ) ? this . db . vpc : props . vpc ,
@@ -130,16 +131,20 @@ export class PgStacDatabase extends Construct {
130131
131132 // if props.lambdaFunctionOptions doesn't have 'code' defined, update pgstac_version (needed for default runtime)
132133 if ( ! props . bootstrapperLambdaFunctionOptions ?. code ) {
133- customResourceProperties [ "pgstac_version" ] = props . pgstacVersion || DEFAULT_PGSTAC_VERSION ;
134+ customResourceProperties [ "pgstac_version" ] =
135+ props . pgstacVersion || DEFAULT_PGSTAC_VERSION ;
134136 }
135- // this.connections = props.database.connections;
137+
138+ // add timestamp to properties to ensure the Lambda gets re-executed on each deploy
139+ customResourceProperties [ "timestamp" ] = new Date ( ) . toISOString ( ) ;
140+
136141 const bootstrapper = new CustomResource ( this , "bootstrapper" , {
137142 serviceToken : handler . functionArn ,
138143 properties : customResourceProperties ,
139144 removalPolicy : RemovalPolicy . RETAIN , // This retains the custom resource (which doesn't really exist), not the database
140145 } ) ;
141146
142- // PgBouncer: connection pooler
147+ // PgBouncer: connection poolercustomresource trigger on redeploy
143148 const addPgbouncer = props . addPgbouncer ?? true ;
144149 if ( addPgbouncer ) {
145150 this . _pgBouncerServer = new PgBouncer ( this , "pgbouncer" , {
@@ -172,6 +177,7 @@ export class PgStacDatabase extends Construct {
172177 this . pgstacSecret = this . _pgBouncerServer . pgbouncerSecret ;
173178 this . connectionTarget = this . _pgBouncerServer . instance ;
174179 this . securityGroup = this . _pgBouncerServer . securityGroup ;
180+ this . secretBootstrapper = this . _pgBouncerServer . secretUpdateComplete ;
175181 } else {
176182 this . connectionTarget = this . db ;
177183 }
@@ -226,10 +232,10 @@ export interface PgStacDatabaseProps extends rds.DatabaseInstanceProps {
226232 readonly pgstacDbName ?: string ;
227233
228234 /**
229- * Version of pgstac to install on the database
230- *
231- * @default 0.8.5
232- */
235+ * Version of pgstac to install on the database
236+ *
237+ * @default 0.8.5
238+ */
233239 readonly pgstacVersion ?: string ;
234240
235241 /**
0 commit comments