• Documentation
  • Pricing
© 2026 Serverless, Inc. All rights reserved.

Framework

  • Overview
  • Documentation
  • Plugins360
  • Pricing

Learn

  • Blog
  • GuidesUpdated
  • Examples240
  • Courses

Resources

  • Support
  • Security
  • Trust Center
  • Status

Community

  • Slack
  • GitHub47k
  • Forum
  • Meetups

Company

  • About
  • Careers
  • Contact
  • Partners

Legal

  • Terms of Service
  • Privacy Policy
  • Trademark
  • DMCA
Serverless Framework Logo

Serverless Framework

Intro
SetupUpgrading To V4ConceptsTutorialAWS CredentialsLicense Keys
DeployingPackagingBuildingTestingServicesFunctions
OverviewHTTP (API Gateway v2)REST (API Gateway v1)ActiveMQApplication Load BalancerAlexa SkillAlexa Smart HomeCloudWatch EventCloudWatch LogCloudFrontCognito User PoolEventBridge EventIoTIoT Fleet ProvisioningKafkaKinesis & DynamoDBMSKRabbitMQS3ScheduleSNSSQSWebsocket
LayersManaged InstancesAlertsVersion PruningDomainsIAM Function PermissionsParameters
OverviewSelf-reference serverless.ymlServerless CoreEnvironment VariablesCLI OptionsExternal YAML/JSON FilesJavascript propertiesGitDoppler
OverviewS3 ObjectsSSM Parameter Store & Secrets ManagerCloudFormation Stack Outputs
OverviewVaultTerraform State Output
ResourcesComposing ServicesDeployment BucketStatePython support
OverviewRuntimeGatewayMemoryBrowserCode InterpreterDev Mode
API Gateway Proxy
OverviewGeneral ConfigurationAuthenticationAPI KeysData SourcesResolversPipeline FunctionsCachingDelta SyncCustom DomainWAFCLI Commands
Deploying SAM/CFN TemplatesWorkflow Tips
OverviewCreating PluginsCLI OutputCustom CommandsCustom VariablesExtending the Configuration schemaExtending and overriding configuration
OverviewDashboardAxiom
Overviewdeploydeploy functiondeploy listdevdiffinfoinvokeinvoke localloginlogin awslogin aws ssologsmetricspackageplugin installplugin uninstallprintprunereconcileremoverollbackrollback functionsupportusage
Overview
OverviewMetricsTracesTroubleshoot
OverviewNode.jsPython
OutputsProviders
OverviewBranch DeploymentsPreview DeploymentsCustom ScriptsTestingPrivate PackagesNotificationsMono ReposDeploy in your own CI/CDBest PracticesTroubleshootingFAQ
OverviewSetupToolsAWS Integration
Serverless.yml Reference
Examples and TutorialsConfiguration Validation
  1. Usage
  2. Layers

AWS Lambda Layers

If you are using AWS as a provider, all layers inside the service are AWS Lambda layers.

Configuration

All of the Lambda layers in your serverless service can be found in serverless.yml under the layers property.

# serverless.yml
service: myService

provider:
  name: aws

layers:
  hello:
    path: layer-dir # required, path to layer contents on disk
    name: ${sls:stage}-layerName # optional, Deployed Lambda layer name
    description: Description of what the lambda layer does # optional, Description to publish to AWS
    compatibleRuntimes: # optional, a list of runtimes this layer is compatible with
      - python3.11
    compatibleArchitectures: # optional, a list of architectures this layer is compatible with
      - x86_64
      - arm64
    licenseInfo: GPLv3 # optional, a string specifying license information
    # allowedAccounts: # optional, a list of AWS account IDs allowed to access this layer.
    #   - '*'
    # note: uncommenting this will give all AWS users access to this layer unconditionally.
    retain: false # optional, false by default. If true, layer versions are not deleted as new ones are created

You can add up to 5 layers as you want within this property.

# serverless.yml

service: myService

provider:
  name: aws

layers:
  layerOne:
    path: layerOne
    description: optional description for your layer
  layerTwo:
    path: layerTwo
  layerThree:
    path: layerThree

Your layers can either inherit their packaging settings from the global package property.

# serverless.yml
service: myService

provider:
  name: aws

package:
  patterns:
    - '!layerSourceTarball.tar.gz'

layers:
  layerOne:
    path: layerOne

Or you can specify them at the layer level.

# serverless.yml
service: myService

provider:
  name: aws

layers:
  layerOne:
    path: layerOne
    package:
      patterns:
        - '!layerSourceTarball.tar.gz'

Keep in mind that all patterns (even when inherited from the service config) are resolved against the layer's path and not the service path.

You can also specify a prebuilt archive to create your layer. When you do this, you do not need to specify the path element of your layer.

# serverless.yml
service: myService

provider:
  name: aws

layers:
  layerOne:
    package:
      artifact: layerSource.zip

Permissions

You can make your layers usable by other accounts by setting the allowedAccounts property:

# serverless.yml
service: myService

provider:
  name: aws

layers:
  layerOne:
    path: layerOne
    allowedAccounts:
      - 111111111111 # a specific account ID
      - 222222222222 # a different specific account ID

Another example, making the layer publicly accessible:

# serverless.yml
service: myService

provider:
  name: aws

layers:
  layerOne:
    path: layerOne
    allowedAccounts:
      - '*' # ALL accounts!

Using your layers

Using the layers configuration key in a function makes it possible for your layer with a function

functions:
  hello:
    handler: handler.hello
    layers:
      - arn:aws:lambda:region:XXXXXX:layer:LayerName:Y

To use a layer with a function in the same service, use a CloudFormation Ref. The name of your layer in the CloudFormation template will be your layer name TitleCased (without spaces) and have LambdaLayer appended to the end. EG:

layers:
  test:
    path: layer
functions:
  hello:
    handler: handler.hello
    layers:
      - !Ref TestLambdaLayer

You can also configure layers at the service level. EG:

# serverless.yml
service: myService

provider:
  name: aws
  runtime: python3.11
  layers:
    - arn:aws:lambda:us-east-1:xxxxxxxxxxxxx:layer:xxxxx:mylayer1
    - arn:aws:lambda:us-east-1:xxxxxxxxxxxxx:layer:xxxxx:mylayer2

functions:
  hello1:
    handler: handler.hello1
  hello2:
    handler: handler.hello2
Edit this page
Prev WebsocketNextManaged Instances

Contents

  • AWS Lambda Layers
  • Configuration
  • Permissions
  • Using your layers

Related

GuidesPluginsExamplesSlack CommunitySupport