GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - cbschuld/sharp-aws-lambda-layer: Prebuilt Sharp AWS Lambda Layer for Node.js 18, 20, and 22. Optimized, bundled, and minified Sharp binaries for x86_64 and arm64 architectures. Improve cold starts with lightweight Sharp builds, ready for Serverless Framework, AWS SAM, and SST deployments.

BranchesTags
Open more actions menu

Latest commit

 

History

32 Commits
32 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
test.mjs
test.mjs
 
 
version.txt
version.txt
 
 

Repository files navigation

Sharp as an AWS Lambda Layer (x86_64 and arm64)

Build Layers GitHub release License issues - sharp-aws-lambda-layer

Prebuilt Sharp AWS Lambda Layer for Node.js 18, 20, 22, and 24. Architecture-specific Sharp binaries for x86_64 and arm64, ready to drop in. Improve cold starts with lightweight Sharp builds, ready for Serverless Framework, AWS SAM, and SST deployments.

About

A pre-built sharp AWS Lambda layer optimized for cold start performance.

  • Supports x86_64 and arm64 architectures.
  • Compatible with Node.js 18.x, 20.x, 22.x, and 24.x runtimes.
  • Automatically updated and tested using GitHub Actions.
  • Architecture-specific native binaries installed straight from npm.
  • Lightweight layer files (~7MB).

Features

  • Separate builds for x64 and arm64.
  • Daily checks designed to auto-release on new sharp versions.
  • Optimized for cold starts on AWS Lambda.
  • Ideal for use with AWS CDK, AWS SAM, SST and Serverless Framework.

Why Separate Builds?

Packaging dependencies and targeting the correct architecture reduces cold start latency dramatically. See Optimizing Node.js dependencies in AWS Lambda for more.

Download

Releases include:

  • release-arm64.zip
  • release-x64.zip
  • release-all.zip

Each file contains a ready-to-use layer for deployment.

Usage

Basic Import

import sharp from 'sharp';

AWS Lambda Layer Setup

Check AWS Lambda Layers documentation.

Publishing a Layer (CLI Example)

aws lambda publish-layer-version \
  --layer-name sharp-lambda-x64 \
  --description "Sharp Layer for x86_64" \
  --license-info "Apache-2.0" \
  --zip-file fileb://release-x64.zip \
  --compatible-runtimes nodejs18.x nodejs20.x nodejs22.x nodejs24.x \
  --compatible-architectures x86_64

aws lambda publish-layer-version \
  --layer-name sharp-lambda-arm64 \
  --description "Sharp Layer for arm64" \
  --license-info "Apache-2.0" \
  --zip-file fileb://release-arm64.zip \
  --compatible-runtimes nodejs18.x nodejs20.x nodejs22.x nodejs24.x \
  --compatible-architectures arm64

AWS CDK Usage Example

import * as lambda from 'aws-cdk-lib/aws-lambda';
import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';

export class MyLambdaStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    const sharpLayer = new lambda.LayerVersion(this, 'SharpLayer', {
      code: lambda.Code.fromAsset('layers/sharp'),
      compatibleArchitectures: [lambda.Architecture.ARM_64],
      compatibleRuntimes: [
        lambda.Runtime.NODEJS_18_X,
        lambda.Runtime.NODEJS_20_X,
        lambda.Runtime.NODEJS_22_X,
        lambda.Runtime.NODEJS_24_X,
      ],
      description: 'Sharp Lambda Layer for ARM64',
      license: 'Apache-2.0',
    });

    const myFunction = new lambda.Function(this, 'MyFunction', {
      runtime: lambda.Runtime.NODEJS_20_X,
      handler: 'index.handler',
      code: lambda.Code.fromAsset('lambda-handler-directory'),
      architecture: lambda.Architecture.ARM_64,
      layers: [sharpLayer],
    });
  }
}

SST Usage Example

layers: [
  new lambda.LayerVersion(stack, "SharpLayer", {
    code: lambda.Code.fromAsset("layers/sharp"),
    compatibleArchitectures: [lambda.Architecture.ARM_64],
  })
]

Serverless Framework Usage Example

In your serverless.yml:

functions:
  myFunction:
    handler: handler.main
    runtime: nodejs20.x
    architecture: arm64
    layers:
      - arn:aws:lambda:us-west-2:123456789012:layer:sharp-v0-34-arm64:1

AWS SAM Usage Example

SharpLayer:
  Type: AWS::Serverless::LayerVersion
  Properties:
    LayerName: sharp
    ContentUri: layers/sharp/release-arm64.zip
    CompatibleArchitectures:
      - arm64
    CompatibleRuntimes:
      - nodejs18.x
      - nodejs20.x
      - nodejs22.x
      - nodejs24.x

Building (Optional)

Layers are built automatically by GitHub Actions when a new Sharp version is released.

If needed manually:

git clone https://github.com/cbschuld/sharp-aws-lambda-layer.git
cd sharp-aws-lambda-layer
# Follow the GitHub Actions workflows for build instructions.

License

Released under Apache 2.0 by @cbschuld.

References

  • Sharp Installation Guide
  • AWS Lambda Layers
  • Optimizing Node.js Dependencies in Lambda

About

Prebuilt Sharp AWS Lambda Layer for Node.js 18, 20, and 22. Optimized, bundled, and minified Sharp binaries for x86_64 and arm64 architectures. Improve cold starts with lightweight Sharp builds, ready for Serverless Framework, AWS SAM, and SST deployments.

Topics

aws-lambdaaws-lambda-layeraws-lambda-layersimagesnodejsnpmserverless-frameworksharpsst

Resources

Readme
Apache-2.0 license
Activity

Stars

32 stars

Watchers

0 watching

Forks

5 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.