@@ -39,6 +39,7 @@ export class PgStacDatabase extends Construct {
39
39
40
40
public readonly connectionTarget : rds . IDatabaseInstance | ec2 . Instance ;
41
41
public readonly securityGroup ?: ec2 . SecurityGroup ;
42
+ public readonly secretBootstrapper ?: CustomResource ;
42
43
43
44
constructor ( scope : Construct , id : string , props : PgStacDatabaseProps ) {
44
45
super ( scope , id ) ;
@@ -79,7 +80,7 @@ export class PgStacDatabase extends Construct {
79
80
code : aws_lambda . Code . fromDockerBuild ( __dirname , {
80
81
file : "bootstrapper_runtime/Dockerfile" ,
81
82
buildArgs : {
82
- PYTHON_VERSION : "3.11"
83
+ PYTHON_VERSION : "3.11" ,
83
84
} ,
84
85
} ) ,
85
86
vpc : hasVpc ( this . db ) ? this . db . vpc : props . vpc ,
@@ -130,16 +131,20 @@ export class PgStacDatabase extends Construct {
130
131
131
132
// if props.lambdaFunctionOptions doesn't have 'code' defined, update pgstac_version (needed for default runtime)
132
133
if ( ! props . bootstrapperLambdaFunctionOptions ?. code ) {
133
- customResourceProperties [ "pgstac_version" ] = props . pgstacVersion || DEFAULT_PGSTAC_VERSION ;
134
+ customResourceProperties [ "pgstac_version" ] =
135
+ props . pgstacVersion || DEFAULT_PGSTAC_VERSION ;
134
136
}
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
+
136
141
const bootstrapper = new CustomResource ( this , "bootstrapper" , {
137
142
serviceToken : handler . functionArn ,
138
143
properties : customResourceProperties ,
139
144
removalPolicy : RemovalPolicy . RETAIN , // This retains the custom resource (which doesn't really exist), not the database
140
145
} ) ;
141
146
142
- // PgBouncer: connection pooler
147
+ // PgBouncer: connection poolercustomresource trigger on redeploy
143
148
const addPgbouncer = props . addPgbouncer ?? true ;
144
149
if ( addPgbouncer ) {
145
150
this . _pgBouncerServer = new PgBouncer ( this , "pgbouncer" , {
@@ -172,6 +177,7 @@ export class PgStacDatabase extends Construct {
172
177
this . pgstacSecret = this . _pgBouncerServer . pgbouncerSecret ;
173
178
this . connectionTarget = this . _pgBouncerServer . instance ;
174
179
this . securityGroup = this . _pgBouncerServer . securityGroup ;
180
+ this . secretBootstrapper = this . _pgBouncerServer . secretUpdateComplete ;
175
181
} else {
176
182
this . connectionTarget = this . db ;
177
183
}
@@ -226,10 +232,10 @@ export interface PgStacDatabaseProps extends rds.DatabaseInstanceProps {
226
232
readonly pgstacDbName ?: string ;
227
233
228
234
/**
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
+ */
233
239
readonly pgstacVersion ?: string ;
234
240
235
241
/**
0 commit comments