Open
Description
Description:
Importing SF client from aws-sdk v2 causes Lambda unresponsive when using esbuild.
Steps to reproduce:
sam init
1.1.AWS Quick Start Templates
1.2.Hello World Example
1.3.nodejs16.x
1.4.Zip
1.5.Hello World Example TypeScript
cd <project>/hello-world
- modify
package.json
and add"aws-sdk": "^2.1342.0"
intodependencies
npm i
- modify
hello-world/app.ts
as below:
import { StepFunctions } from 'aws-sdk';
export const lambdaHandler = async () => {
console.log("Before initializing SF client");
const sfClient = new StepFunctions();
console.log("After initializing SF client");
};
cd ..
sam build
sam deploy --guided
and confirm the deployment with the defaults- head over to AWS console and locate deployed lambda
- execute the Lambda
Observed result:
Lambda times out. If the function's timeout is increased to let's say 30 seconds, it runs out of memory (128MB by default in my case). Pre-initializing logs are not displayed, which means that Lambda probably hangs out when importing StepFunctions client.
I checked other AWS-SDK v2 clients like S3, DocumentClient and it works without any issue.
I've also noticed that when I change
import { StepFunctions } from 'aws-sdk';
into the below:
import StepFunctions from 'aws-sdk/clients/stepfunctions';
it starts working.
Expected result:
Importing & initializing StepFunctions
from aws-sdk v2 works as expected and doesn't cause lambda timeouts/memory outages - basically doesn't make Lambda not responsive.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS:
macOS-13.0.1-x86_64-i386-64bit
sam --version
:SAM CLI, version 1.76.0
- AWS region:
eu-west-1
- esbuild:
"esbuild": "^0.14.14"
{
"version": "1.76.0",
"system": {
"python": "3.11.2",
"os": "macOS-13.0.1-x86_64-i386-64bit"
},
"additional_dependencies": {
"docker_engine": "20.10.20",
"aws_cdk": "2.69.0 (build 60a5b2a)",
"terraform": "1.0.0"
}
}