Serverless Framework Gotmes

Installing binaries within AWS lambda using layers

My bot uses ffmpeg to produce the audio clips. In a serverless environment, I needed to make sure that my lambda had access to the ffmpeg program on disk to run my lambda function AWS lambda provides a way to use binaries using aws layers. The layer concept allows developers to install programs in the serverless environment to be used by your lambda program. The serverless framework provides an interface to use layers via serverless.yml. More documentation on layers here

Serverless upload size

An error occurred: AppLambdaFunction - Unzipped size must be smaller than 185965792 bytes

AWS has a hard limit for the unzipped size of your lambda function. What helped me trim my deployment:

  • Remove all serverless plugins upon uploading your program. Alternatively, a plugin can help reduce node lambda deployments. See the serverless webpack plugin for more information
  • Make sure to only package required development dependencies
  • Trim down packages installed within your layers. For an example, ffmpeg comes with docs, libs, and binaries that were not necessary.

Debugging deployments

Development logs from within the UI seemed to truncate 90% of the information. Tailing the logs was the best way for me to debug my deployed application.

serverless logs -f <application-name> -t

Leave a Reply

Your email address will not be published. Required fields are marked *