Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lambda layers to releases #1772

Closed
jlarmstrongiv opened this issue Jul 2, 2019 · 15 comments
Closed

Add lambda layers to releases #1772

jlarmstrongiv opened this issue Jul 2, 2019 · 15 comments

Comments

@jlarmstrongiv
Copy link

What are you trying to achieve?

AWS released Lambda Layers to facilitate sharing libraries and binaries across lambda functions.

With Lambda Layers, adopting Sharp.js into any AWS Lambda Node.js project will be a breeze. Plus, there will be less setup, confusion, and errors surrounding compiling for the lambda execution environment.

I appreciate the existing installation instructions for AWS Lambda, and I think Lambda Layers could augment them.

What would you expect the API to look like?

With the releases, also publish the arn of the Lambda Layer for that particular version. This step could be automated into the build process. The docs for installation will need to be updated accordingly.

What alternatives have you considered?

Setting up my own Lambda Layer. Will often be out of date and more error prone.

Building and packaging Sharp.js each time. Build and upload speed will be slower and maintaining versions and consistency across multiple lambda functions will be difficult.

Is there a sample image that helps explain?

N/A. Here are more links about lambda layers:

There are other tutorials for creating a Lambda Layer online.

Loving Sharp.js! Just hoping to use it in more places 😄

@lovell
Copy link
Owner

lovell commented Jul 2, 2019

Hello, I'm happy for the docs to link to public, third-party, well-maintained Lambda Layer(s) in the same way there are links to Docker images of a likewise nature.

I'm sure it won't be long before AWS provides a Lambda Layer Marketplace, at which point I might consider providing "official" layers at a small cost.

I regularly take on paid consulting should anyone wish me to create and maintain either private or public Lambda Layers custom to their needs - please feel free to send an email if this would be of interest to you or anyone else reading this.

@jlarmstrongiv
Copy link
Author

jlarmstrongiv commented Jul 2, 2019

@Exonis any interest in publishing your third-party Lambda Layer? 🙏

I’m just a student so I can’t afford consulting services yet 😅

Otherwise, I’ll probably just use the prebuilt tarballs or use a similar build step.

@Umkus
Copy link

Umkus commented Mar 16, 2020

@jlarmstrongiv There are several solutions on github that generate a layer zip-file with sharp.

I also recently created one with the (currently) latest version - https://github.com/Umkus/lambda-layer-sharp.

@tommedema
Copy link

AWS now provides the "Lambda Layer Marketplace" @lovell: https://serverlessrepo.aws.amazon.com/applications

E.g. imagemagick is on here at https://serverlessrepo.aws.amazon.com/applications/arn:aws:serverlessrepo:us-east-1:145266761615:applications~image-magick-lambda-layer

Using it in a serverless function with the serverless framework is as simple as:

functions:
  genThumbnailFromPNG:
    handler: dist/transform.thumbnailFromPNG
    layers:
      - !GetAtt IMLambdaLayer.Outputs.LayerVersion
    events:
      - s3:
          existing: true
          bucket: ${{env:AWS_S3_MEDIA_BUCKET_NAME}}
          event: s3:ObjectCreated:*
          rules:
            - prefix: public/
            - suffix: screenshot.png

resources:
  Transform: AWS::Serverless-2016-10-31
  Resources:
    IMLambdaLayer:
      Type: AWS::Serverless::Application
      Properties:
        Location:
          ApplicationId: arn:aws:serverlessrepo:us-east-1:145266761615:applications/image-magick-lambda-layer
          SemanticVersion: 1.0.0

Would be great if we can have the same plug-and-play solution with Sharp

@Dramex
Copy link

Dramex commented Oct 15, 2020

I'm looking for a (zip) layer with gif support.
#2012 (comment)

I couldn't do it myself I run into multiple issues with Docker. help appreciated ❤️

@Dramex
Copy link

Dramex commented Oct 18, 2020

please feel free to send an email if this would be of interest to you or anyone else reading this.

@lovell would you able to reply to my email? I sent it on Thursday. ❤️

@zoellner
Copy link

zoellner commented Jan 7, 2021

For anyone coming here looking for a lambda layer: I've created one that includes sharp with HEIC/HEIF support: https://github.com/zoellner/sharp-heic-lambda-layer
It can be added to any lambda function. See repo for details.

@tommedema
Copy link

@zoellner this is awesome, any chance you can submit it to the AWS serverless application repository?

@zoellner
Copy link

zoellner commented Jan 7, 2021

@tommedema added it to the repository and added some more details to the readme: https://serverlessrepo.aws.amazon.com/applications/us-east-1/776954778331/sharp-heic

@tommedema
Copy link

awesome, thanks!

@lovell
Copy link
Owner

lovell commented Jan 8, 2021

@zoellner It looks like you have published binary files (not source code) to AWS containing patent-encumbered HEVC logic. If so, please be aware this will expose you or your employer to potential royalty payments to patent pools/holders for every copy "downloaded". This might be construed under law to mean every time anyone deploys a Lambda function that uses it.

@zoellner
Copy link

zoellner commented Jan 8, 2021

Thanks for the note. In order to stay on the safe side, I modified the repo to make it more suitable for self hosting and removed the application from the serverless application repository

@tommedema
Copy link

Would be great to get a non-hevc version of sharp published on the application repository. This makes it super easy to use sharp with lambda

@hansottowirtz
Copy link

I automated the zip-building with Github Actions and Dependabot here: bubblydoo/lambda-layer-sharp.
Every time a new Sharp version is released, a new PR is automatically opened by Dependabot and a new zip is published to the releases page after merging.

@lovell
Copy link
Owner

lovell commented Jan 10, 2022

I'll close this issue as, from the comments, it looks like there are now some good solutions to this. Many thanks to those who've created and maintain these layers.

@lovell lovell closed this as completed Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants