thankful-ambulance-76337
02/08/2024, 10:39 PMapi error RequestEntityTooLargeException: Request must be smaller than 70167211 bytes for the CreateFunction operation
const myLambda = new aws.lambda.Function(
"myLambda",
{
code: new pulumi.asset.AssetArchive({
".": new pulumi.asset.FileArchive("./lambdas/typescript_proj1"),
}),
handler: "src/index.handler",
runtime: "nodejs18.x",
role: lambdaRole.arn,
timeout: 120,
}
)
My thought is this actually has something to do with typescript. Especially since CF allows me to pass in a BuildMethod of esbuild but there’s no equivelent in pulumi that i can findwide-nest-220
02/09/2024, 3:20 PMwide-nest-220
02/09/2024, 3:21 PMmagnificent-soccer-44287
02/11/2024, 2:00 PMindex.ts
lambda/s3-retrieval.js
lambda/package.json
you'd use:
code: new pulumi.asset.FileArchive("./lambda"),
runtime: aws.lambda.Runtime.NodeJS20dX,
handler: 's3-retrieval.handler',
tracingConfig: {
mode: "Active",
},
memorySize: 256,
timeout: 10,
role: lambdaRole.arn,
environment: {
variables: {
BUCKET_NAME: assetsBucket.bucket,
},
},
A few things:
a) There is no need to use AssetArchive - FileArchive zips the entire folder it points to.
b) Within that folder, the handler is [fileName].[methodName]
So above:
/lambda/s3-retrieval.js : handler
is what gets invoked. If the entire folders' size (including node_modules) is too large, you'd see that message. You can reduce your node_modules size (assuming this is indeed the issue and you haven't ran into a legitimate bug) by using AWS SDKv3 - specific imports, as such:
import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3";
import { gzipSync } from "zlib";
the SDK v3 imports and usage are very different from the SDK v2. This has caused me a lot of grief before.magnificent-soccer-44287
02/11/2024, 2:01 PM{
"private": "true",
"type": "module"
}
or an mjs extension in the file containing the handler.