capabilities.work

Publish a Layer Version and Attach It to a Function

A 4-step recipe with AWS Lambda. We can help you get access.

Recipe · 4 steps

Publish a Layer Version and Attach It to a Function

with AWS Lambda · IT Infrastructure Management

Publish a new layer version and wire it into a function's configuration.

  1. Publish a new immutable version of the layer from the staged S3 archive. The version number increments on every call; existing versions are never overwritten, so functions pinned to an older version are unaffected.
  2. Read the published version back to confirm the archive landed and to see the runtime compatibility Lambda recorded, before any function is pointed at it.
  3. Update the function to reference the new layer version ARN. The Layers list is replaced wholesale rather than appended to, so the caller supplies the full intended set through this single new ARN.
  4. Poll until LastUpdateStatus reports "Successful". Until then the function is still being provisioned with the new layer and invocations continue to use the previous configuration.
What you'll need to have ready
  • layerName: The name of the layer to publish a new version of.
  • functionName: The name or ARN of the function the layer is attached to.
  • s3Bucket: The S3 bucket holding the layer archive ZIP.
  • s3Key: The S3 key of the layer archive ZIP.
  • compatibleRuntimes: Runtimes this layer supports (e.g. ["nodejs20.x"]). Lambda rejects attaching a layer to an incompatible runtime.
  • compatibleArchitectures: Instruction set architectures this layer supports (x86_64 and/or arm64).
  • layerDescription: Description recorded against the published layer version.
  • licenseInfo: The layer's software license (an SPDX identifier, a URL, or the full text).
For your developer

Arazzo workflow aws-lambda:publish-layer-and-attach, 4 operations: PublishLayerVersion → GetLayerVersion → UpdateFunctionConfiguration → GetFunctionConfiguration. Specs on APIs.io.