Skip to content

Go+Lambda LocalStack error fork/exec /var/task/bootstrap: no such file or directory #12291

@krishna-mfw

Description

@krishna-mfw

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.

  1. aws --endpoint-url=http://localhost:4566/ s3api create-bucket --bucket zip-lambda --create-bucket-configuration LocationConstraint=ap-northeast-1
  2. aws --endpoint-url=http://localhost:4566/ s3 cp lambda.zip s3://zip-lambda/lambda.zip
  3. 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}'

Metadata

Metadata

Assignees

No one assigned

    Labels

    aws:lambdaAWS Lambdatype: questionPlease ask questions on our community slack (slack.localstack.cloud)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions