Skip to content

allenheltondev/aws-lambda-layer-types

Repository files navigation

Twitter GitHub LinkedIn Medium

AWS Lambda Layer Types Example

Description

This is an example of how to create and use the two different types of lambda layers: Dependency and Function. This repository is an example of how you would build a serverless HTTP API for maintaining a list of contacts and sending text messages to them. For a detailed walkthrough, reference the article on Medium.

AWS Resources

The CloudFormation template will deploy the follow resources into your AWS account

  • 1 x Public API (API Gateway)
  • 1 x NoSQL Table (DynamoDB)
  • 6 x CRUD Functions (Lambda)
  • 6 x Roles with Policies (IAM)
  • 2 x Lambda Layers (Lambda Layer Version)

Prerequisites

In order to properly run and deploy this app, you must perform the following

  1. Setup an AWS account
  2. Install the AWS CLI
  3. Configure the AWS CLI to use your account
  4. Install Git

Optional

If you want to actually send text messages, set up an account on Twilio

  1. Sign up for an account
  2. Purchase a phone number
  3. Find and Record your Account Sid and Auth Token

Setup

  1. Clone the repository to your local machine
  2. In the root package.json, change REPLACEME with the name of an S3 bucket to create in your account. a. S3 bucket names in AWS have to be globally unique, so be sure to use something nobody has used before
  3. Run npm run provision-bucket to create the S3 bucket in your AWS account
  4. In the template.yaml file, change the S3BucketName Default REPLACEME with the name of your bucket
  5. Optional In the template.yaml file, change the TwilioAccountSid, TwilioAuthToken, and TwilioFromNumber Default REPLACEME with your values from the optional prerequsite steps

Deployment

You are able to deploy the solution any way you'd like, but included in the root package.json is a script that will automatically build, package, and deploy the solution to AWS for you. Just run the following command to deploy

npm run deploy

Request

If you are able to contribute back, I'd appreciate help on parameterizing the package.json to use a config object so users don't have to replace REPLACEME in so many places. I'd like to use a configuration variable in the scripts like $npm_package_config_bucketname, but I have been unsuccessful on my Windows machine in getting that to resolve.

About

Shows how to build the two types of lambda layers in node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published