Home > Blockchain >  editing aws lambda inline with large package size
editing aws lambda inline with large package size

Time:01-18

I have an AWS Lambda function that only has 3 files in the working directory. Two of these files are Linux binaries that I need to execute (via spawnSync) whenever the function.

The issue is that one of these binaries is almost 80MB in size, making the package size far too big. This means that I cannot edit the code or file structure or deploy and test via the Lambda inline editor.

As I'm extremely new to the AWS environment, this makes it very difficult to learn and debug.

So, how should I go about editing the codebase of my Lambda functions when they exceed 25MB? Is this something that I should be handling via GitHub? Should I be storing my massive binaries somewhere else and calling them from there?

CodePudding user response:

As mentioned in lambda quotas. You wont be able to see/edit the code if its over 3MB

There are plenty of options to deal with this.

  1. You can use lambda layers

A Lambda layer is a .zip file archive that can contain additional code or other content. A layer can contain libraries, a custom runtime, data, or configuration files. Use layers to reduce deployment package size and to promote code sharing and separation of responsibilities so that you can iterate faster on writing business logic.

In simple words, you can reduce your package size by uploading your binary as a layer and accessing it inside the lambda. I wrote a blog on this for better understanding. https://dev.classmethod.jp/articles/simplify-your-lambda-dependencies-with-lambda-layers/

  1. You can use an IaC Tool like AWS CDK or Terraform ( not suite for typescript based lambda, rest python or any other language is fine ). With IaC you will simple work in your local editor like vscode, and using IaC you will deploy your lambda function.So now you have the flexibility to use your IDE for development and then deploy lambda to account using IaC tool. CDK will handle all the lambda permissions and connections for you.
  2. You might have tried this but still uploading it as a zip package, carefully excluding SDK packages because it's available in runtime( node.js lambda)

Reducing your lambda deployment package size is listed best practice.. These are little advanced ways:

  • Using S3
  • Using EFS
  • Container Image

CodePudding user response:

You won't be able to use the inline editor on AWS Console due to size limits. You need to do the edits wherever your code is written.

  • Related