I have a simple lambda consisting of index.js
and node_modules
. When I zip these two files (either by zipping both directly or by zipping the parent directory), it places them inside a folder which is then zipped.
I then upload this zip to my S3 bucket which works fine.
My Lambda however, can't find the right files because it seems to have nested the index.js
handler inside an extra directory (I assume this happens from the zipping)
I am using Terraform to create my Lambda function which references the S3 bucket:
resource "aws_lambda_function" "Lambda" {
s3_bucket = var.bucket_id
s3_key = "on-sign-in-trigger.zip"
handler = "index.handler"
runtime = "nodejs18.x"
role = aws_iam_role.lambda_iam_role.arn
function_name = "on-sign-in-trigger-${var.env_name}"
}
Do I need to configure Lambda so that it knows to go a folder deeper to get the handler function or is there another way I should be zipping / uploading my code to S3?