Convert Figma logo to code with AI

aws-samples logoserverless-patterns

Serverless patterns. Learn more at the website: https://serverlessland.com/patterns.

1,571
920
1,571
77

Top Related Projects

⚡ Serverless Framework – Effortlessly build apps that auto-scale, incur zero costs when idle, and require minimal maintenance using AWS Lambda and other managed cloud services.

Run Express and other Node.js frameworks on AWS Serverless technologies such as Lambda, API Gateway, Lambda@Edge, and more.

11,501

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code

10,636

Python Serverless Microframework for AWS

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM

Quick Overview

The aws-samples/serverless-patterns repository is a collection of serverless architecture patterns and sample projects for AWS services. It provides developers with ready-to-deploy examples of common serverless use cases, demonstrating best practices and integration between various AWS services. The repository aims to accelerate serverless development and learning on the AWS platform.

Pros

  • Extensive collection of serverless patterns covering a wide range of AWS services
  • Ready-to-deploy examples with infrastructure-as-code templates (CloudFormation, SAM, CDK)
  • Well-documented patterns with architecture diagrams and explanations
  • Regularly updated with new patterns and improvements

Cons

  • Some patterns may become outdated as AWS services evolve
  • Not all patterns are available in all infrastructure-as-code formats (e.g., some may only have CloudFormation but not CDK)
  • Limited coverage of advanced or complex serverless architectures
  • May require additional customization for production use cases

Getting Started

To get started with the aws-samples/serverless-patterns repository:

  1. Clone the repository:

    git clone https://github.com/aws-samples/serverless-patterns.git
    
  2. Navigate to the desired pattern directory:

    cd serverless-patterns/<pattern-name>
    
  3. Follow the README instructions in the pattern directory for deployment steps, which typically involve using AWS SAM, AWS CDK, or AWS CloudFormation.

  4. Explore the code and architecture to understand the pattern implementation.

  5. Modify and adapt the pattern to fit your specific use case.

Competitor Comparisons

⚡ Serverless Framework – Effortlessly build apps that auto-scale, incur zero costs when idle, and require minimal maintenance using AWS Lambda and other managed cloud services.

Pros of Serverless

  • Framework-agnostic, supporting multiple cloud providers (AWS, Azure, GCP)
  • Extensive plugin ecosystem for enhanced functionality
  • Active community and regular updates

Cons of Serverless

  • Steeper learning curve for beginners
  • More complex configuration for advanced use cases
  • May require additional setup for local development and testing

Code Comparison

Serverless:

service: my-service
provider:
  name: aws
  runtime: nodejs14.x
functions:
  hello:
    handler: handler.hello

Serverless-patterns:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs14.x

Key Differences

  • Serverless-patterns focuses exclusively on AWS, while Serverless supports multiple cloud providers
  • Serverless-patterns provides ready-to-deploy examples, whereas Serverless offers a more customizable framework
  • Serverless-patterns uses AWS SAM syntax, while Serverless uses its own configuration format

Use Cases

  • Choose Serverless for multi-cloud projects or when extensive customization is needed
  • Opt for Serverless-patterns when focusing on AWS and seeking quick, deployable examples

Community and Support

  • Serverless has a larger community and more third-party resources
  • Serverless-patterns benefits from direct AWS support and documentation

Run Express and other Node.js frameworks on AWS Serverless technologies such as Lambda, API Gateway, Lambda@Edge, and more.

Pros of serverless-express

  • Focused specifically on Express.js applications, providing a streamlined solution for serverless Express deployments
  • Includes built-in middleware and utilities tailored for serverless Express environments
  • Offers a simpler learning curve for developers already familiar with Express.js

Cons of serverless-express

  • Limited to Express.js applications, lacking the broader scope of serverless patterns covered in serverless-patterns
  • May not provide as many examples or use cases for different serverless architectures and services
  • Potentially less comprehensive documentation compared to the AWS-maintained serverless-patterns repository

Code Comparison

serverless-express:

const serverlessExpress = require('@vendia/serverless-express')
const app = require('./app')
exports.handler = serverlessExpress({ app })

serverless-patterns:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs14.x

The serverless-express example shows a simple Express.js application wrapped for serverless deployment, while the serverless-patterns example demonstrates a more generic AWS SAM template for a Lambda function. serverless-patterns covers a wider range of serverless architectures and services, whereas serverless-express focuses specifically on Express.js applications in serverless environments.

11,501

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code

Pros of aws-cdk

  • Comprehensive infrastructure-as-code solution for AWS resources
  • Supports multiple programming languages (TypeScript, Python, Java, etc.)
  • Offers higher-level constructs for easier resource management

Cons of aws-cdk

  • Steeper learning curve for beginners
  • Requires knowledge of a supported programming language
  • More complex setup compared to simple CloudFormation templates

Code Comparison

aws-cdk:

import * as cdk from 'aws-cdk-lib';
import * as lambda from 'aws-cdk-lib/aws-lambda';

const stack = new cdk.Stack(app, 'MyStack');
new lambda.Function(stack, 'MyLambda', {
  runtime: lambda.Runtime.NODEJS_14_X,
  handler: 'index.handler',
  code: lambda.Code.fromAsset('lambda')
});

serverless-patterns:

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  MyLambdaFunction:
    Type: AWS::Lambda::Function
    Properties:
      Runtime: nodejs14.x
      Handler: index.handler
      Code:
        S3Bucket: my-bucket
        S3Key: lambda.zip

The aws-cdk repository provides a full-fledged framework for defining AWS infrastructure using familiar programming languages, offering more flexibility and abstraction. In contrast, serverless-patterns focuses on providing ready-to-use CloudFormation templates for common serverless architectures, making it easier for beginners to get started but with less customization options.

10,636

Python Serverless Microframework for AWS

Pros of Chalice

  • Simplified Python-based framework for serverless applications
  • Automatic API Gateway integration and deployment
  • Built-in support for AWS Lambda function management

Cons of Chalice

  • Limited to Python development, less flexible for multi-language projects
  • Fewer pre-built patterns and examples compared to Serverless Patterns
  • May require more custom configuration for complex architectures

Code Comparison

Chalice example:

from chalice import Chalice

app = Chalice(app_name='helloworld')

@app.route('/')
def index():
    return {'hello': 'world'}

Serverless Patterns example (SAM template):

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs14.x
      Events:
        HelloWorld:
          Type: Api
          Properties:
            Path: /hello
            Method: get

Chalice focuses on a Python-centric approach with a clean, decorator-based syntax for defining routes and functions. Serverless Patterns, on the other hand, provides a wider range of language support and uses infrastructure-as-code templates to define resources and their relationships.

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM

Pros of aws-sam-cli

  • Provides a complete CLI tool for developing, testing, and deploying serverless applications
  • Offers local testing and debugging capabilities for Lambda functions
  • Integrates seamlessly with AWS services and supports multiple programming languages

Cons of aws-sam-cli

  • Steeper learning curve for beginners compared to ready-made patterns
  • Requires more setup and configuration for complex serverless architectures
  • May not cover all possible serverless patterns out-of-the-box

Code Comparison

serverless-patterns:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler

aws-sam-cli:

version: 0.2
phases:
  build:
    commands:
      - sam build
  post_build:
    commands:
      - sam package --s3-bucket ${S3_BUCKET} --output-template-file packaged.yaml

The serverless-patterns repository provides pre-built templates for various serverless architectures, while aws-sam-cli offers a more flexible development environment with local testing capabilities. Serverless-patterns is ideal for quick deployments of common patterns, whereas aws-sam-cli is better suited for custom serverless application development and testing.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

AWS serverless patterns

This repo contains serverless patterns showing how to integrate services using infrastructure-as-code (IaC). You can use these patterns to help develop your own projects quickly.

Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the AWS Pricing page for details. You are responsible for any AWS costs incurred. No warranty is implied in this example.

Requirements

  • AWS CLI already configured with Administrator permission

Deployment Instructions

  1. Create an AWS account if you do not already have one and login.

  2. Install Git and install the AWS Serverless Application Model CLI on your local machine.

  3. Create a new directory and navigate to that directory in a terminal.

  4. Clone this repo

git clone https://github.com/aws-samples/serverless-patterns

Each subdirectory contains additional installation and usage instructions.

Ownership

This project is owned, managed, and maintained by the AWS Serverless Developer Advocacy team, consisting of James Beswick, Dave Boyne, Eric Johnson, Ben Smith, Marcia Villalba, and Julian Wood. To contact us, raise an issue on this repo.


Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.

SPDX-License-Identifier: MIT-0