Skip to content

Technology Series: Deploying Lambda Functions and Layers on AWS

Technology Series: Deploying Lambda Functions and Layers on AWS

  • 1 Minute Read

In our last article, we talked about AWS SAM (Serverless Application Model) and how to run an end-to-end application locally.

We'll be using the same code that we used to create a lambda and a small layer and deploy it to AWS.

Template File

Just like with SAM, we need a template file to deploy our Lambda function and its associated layer.

If we look at the layer definition, we can spot a couple of differences:

  • RetentionPolicy: This is now set to Delete instead of Retain
  • ContentUri: Instead of specifying the location of the code, we refer to a S3 bucket

We had to change the retention policy because otherwise, the layer would not get updated on AWS and the Lambda would end up re-using the existing version, which is not what we want if we made changes to the layer.

Also, we don't want to specify a particular layer version, because we just don't know what i will be. Instead we indicate that the layer's code is in a ZIP file that's stored on S3.

Swagger Spec

Another difference is that while we had a smallish swagger spec in our original template, we now need a swagger spec that's in a separate file (because it's easier to read and because we can export it from AWS to begin with).

You can find our swagger.yaml here

Related Articles