Skip to content

Commit 5ed3e57

Browse files
committed
refactor: standardize Lambda bundling configuration
1 parent 2fab975 commit 5ed3e57

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

typescript/postgres-lambda/lib/postgres-lambda-stack.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,20 @@ export class PostgresLambdaStack extends cdk.Stack {
3030
credentials: rds.Credentials.fromGeneratedSecret('postgres'),
3131
});
3232

33+
const bundleCommand = [
34+
'bash', '-c', [
35+
'cp -r . /asset-output/',
36+
].join(' && ')
37+
]
38+
3339
// Create a Lambda function that calls PostgreSQL with Docker bundling
3440
const lambdaToPostgres = new lambda.Function(this, 'LambdaToPostgres', {
3541
runtime: lambda.Runtime.NODEJS_LATEST,
3642
handler: 'index.handler',
3743
code: lambda.Code.fromAsset(path.join(__dirname, '../lambda/lambda-to-postgres'), {
3844
bundling: {
39-
image: cdk.DockerImage.fromRegistry('public.ecr.aws/sam/build-nodejs18.x'),
40-
command: [
41-
'bash', '-c', [
42-
'cp -r . /asset-output/'
43-
].join(' && ')
44-
],
45-
user: '1000',
45+
image: lambda.Runtime.NODEJS_LATEST.bundlingImage,
46+
command: bundleCommand,
4647
},
4748
}),
4849
vpc,
@@ -68,13 +69,8 @@ export class PostgresLambdaStack extends cdk.Stack {
6869
handler: 'index.handler',
6970
code: lambda.Code.fromAsset(path.join(__dirname, '../lambda/postgres-to-lambda'), {
7071
bundling: {
71-
image: cdk.DockerImage.fromRegistry('public.ecr.aws/sam/build-nodejs18.x'),
72-
command: [
73-
'bash', '-c', [
74-
'cp -r . /asset-output/'
75-
].join(' && ')
76-
],
77-
user: '1000',
72+
image: lambda.Runtime.NODEJS_LATEST.bundlingImage,
73+
command: bundleCommand,
7874
},
7975
}),
8076
environment: {
@@ -111,13 +107,8 @@ export class PostgresLambdaStack extends cdk.Stack {
111107
handler: 'index.handler',
112108
code: lambda.Code.fromAsset(path.join(__dirname, '../lambda/postgres-setup'), {
113109
bundling: {
114-
image: cdk.DockerImage.fromRegistry('public.ecr.aws/sam/build-nodejs18.x'),
115-
command: [
116-
'bash', '-c', [
117-
'cp -r . /asset-output/'
118-
].join(' && ')
119-
],
120-
user: '1000',
110+
image: lambda.Runtime.NODEJS_LATEST.bundlingImage,
111+
command: bundleCommand,
121112
},
122113
}),
123114
vpc,

0 commit comments

Comments
 (0)