The Serverless Samples project contains a multitude of examples of serverless applications. Detailed concepts such as REST APIs, DynamoDB, and security, are explored gradually across multiple samples to focus on one specific concept, technique, or pattern.
The project contains several samples demonstrating how to create a REST API using Amazon API Gateway and AWS Lambda functions. The Lambda functions provide examples of C
pdate, and D
elete resource endpoints. Lambda functions are a fully serverless operational platform, requiring no compute resource provisioning (i.e. servers), allowing you to focus on feature development.
Amazon DynamoDB is a highly scalable and completely serverless database solution. The project provides a number of sample Lambda functions that persist data in DynamoDB.
Security is an essential element of any information system. The project contains samples of Lambda Authorizers, formerly called Custom Authorizers. Lambda authorizers are simply Lambda functions which serve solely to authenticate Amazon API Gateway requests. Looking for a Lambda Authorizer leveraging JSON Web Tokens (JWT)? Look no further.
In addition to Lambda Authorizers, API Gateway endpoints may be secured by AWS Cognito User Pools. The project contains samples of Cognito Authorizers. Cognito authorizers authenticate identity or access tokens sent in Amazon API Gateway requests.
Shared API Gateways
By default, the Serverless Framework creates a distinct API Gateway for each project. Sometimes it is desirable to break apart a large REST API into many smaller, domain-specific service components. Perhaps different teams are responsible for certain domains. Or perhaps the each component has a distinct application lifecycle. Perhaps you are developing a microservices architecture. Whatever the reason, the Serverless Samples project illustrates how to share a single API Gateway across multiple serverless applications.
Custom Domain Names
When they are created, Amazon API Gateways are assigned a large, cryptic, public domain name. You could manually create a DNS alias for this auto-generated domain name. But using the Serverless Framework's plugin system, it is easy to create and manage custom domain names for API Gateway APIs. Project samples show how to configure the Serverless specification and the CLI commands to manage Custom Domain Names.
AWS Step Function State Machines are a great tool in the Serverless toolbox. Step Function State Machines are asynchronous, rule-driven, and fault-tolerant orchestrations of multiple AWS Lambda functions or Step Function activities. This project contains samples illustrating the use of Serverless Framework plugins to define State Machines within the serverless specification and how to invoke the State Machines via events or the AWS SDK.
Almost every application has some environment-specific configuration. Serverless applications are no exception. The project contains examples of configuring AWS Lambda functions using environment variables sourced from a variety of locations.
One of the most frequent misconceptions of serverless application development is that the code is by default small
, or all in one file or method
. There are times when this is true, but complexity in information systems is unavoidable and the aforementioned situations are rare. Serverless programming does not inherently remove the need to manage complexity... It removes the need to manage servers
. This project contains examples of how to structure serverless projects, organizing code into modules by purpose, maximizing reusability and improving testability.
The project contains samples illustrating how to configure and author unit tests with the Jest library.
- AWS SDK
- Serverless Framework
- Serverless Framework Plugins