-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
We are trying to set up a Lambda in LocalStack and facing issues.We have tried comparing our build process with the Lambda Go docs everything seems okay!
Goal:
Deploy the lambda which is built in Go for our application
Tools:
We are using Kubernetes and LocalStack 3 for this setup
Issue:
We are facing an error fork/exec /var/task/bootstrap: no such file or directory
Summary:
We have a Dockerfile that is built and pushed to ECR. We don't have a PRO plan to use container images to deploy the lambda so what we do is mount a container that is based on this Dockerfile and share its volume to another container where we run LocalStack. By doing so, we make the necessary assets and bootstrap available to the LocalStack container to create a function. Here is our Kubernetes deployment.
The zip file looks fine when extracting the contents
ls -la
total 61268
drwxr-xr-x 1 root root 23 Feb 20 09:13 .
drwxr-xr-x 1 root root 73 Feb 20 09:22 ..
-rw-r--r-- 1 root root 83 Feb 20 09:00 .env
drwxr-xr-x 1 root root 22 Feb 20 09:00 assets
-rwxr-xr-x 1 root root 62734112 Feb 20 09:13 bootstrap
Since the zip file size is more than 50MB we opted to create an S3 in LocalStack and upload this Zip file and create the Lambda function pointing to S3. Below are the commands used for this.
aws --endpoint-url=http://localhost:4566/ s3api create-bucket --bucket zip-lambda --create-bucket-configuration LocationConstraint=ap-northeast-1
aws --endpoint-url=http://localhost:4566/ s3 cp lambda.zip s3://zip-lambda/lambda.zip
aws --endpoint-url=http://localhost:4566/ lambda create-function --function-name test --runtime provided.al2023 --architectures arm64 --handler bootstrap --code S3Bucket=zip-lambda,S3Key=lambda.zip --role arn:aws:iam::000000000000:role/lambda-role --timeout 300 --memory-size 512 --ephemeral-storage '{"Size": 2048}'