Skip to content

Commit 78b635f

Browse files
committed
fix bootstrap function and update jsii
1 parent b8c1b60 commit 78b635f

File tree

3 files changed

+186
-321
lines changed

3 files changed

+186
-321
lines changed

lib/database/PgBouncer.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ export class PgBouncer extends Construct {
186186
runtime: lambda.Runtime.NODEJS_20_X,
187187
handler: "index.handler",
188188
code: lambda.Code.fromInline(`
189-
const AWS = require('aws-sdk');
190-
const sm = new AWS.SecretsManager();
189+
const { SecretsManagerClient, GetSecretValueCommand, PutSecretValueCommand } = require('@aws-sdk/client-secrets-manager');
190+
const client = new SecretsManagerClient();
191191
192192
exports.handler = async (event) => {
193193
console.log('Event:', JSON.stringify(event, null, 2));
@@ -196,21 +196,25 @@ export class PgBouncer extends Construct {
196196
const instanceIp = event.ResourceProperties.instanceIp;
197197
198198
// Get the original secret value
199-
const originalSecret = await sm.getSecretValue({
200-
SecretId: '${props.database.secret.secretArn}'
201-
}).promise();
199+
const getSecretResponse = await client.send(
200+
new GetSecretValueCommand({
201+
SecretId: '${props.database.secret.secretArn}'
202+
})
203+
);
202204
203205
// Parse the secret string
204-
const secretData = JSON.parse(originalSecret.SecretString);
206+
const secretData = JSON.parse(getSecretResponse.SecretString);
205207
206208
// Update the host value with the PgBouncer instance IP
207209
secretData.host = instanceIp;
208210
209211
// Put the modified secret value
210-
await sm.putSecretValue({
211-
SecretId: '${this.pgbouncerSecret.secretArn}',
212-
SecretString: JSON.stringify(secretData)
213-
}).promise();
212+
await client.send(
213+
new PutSecretValueCommand({
214+
SecretId: '${this.pgbouncerSecret.secretArn}',
215+
SecretString: JSON.stringify(secretData)
216+
})
217+
);
214218
215219
return {
216220
PhysicalResourceId: '${this.pgbouncerSecret.secretArn}',

0 commit comments

Comments
 (0)