• Stars
    star
    379
  • Rank 113,004 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ“¦ ⚑ πŸš€ Boilerplate to organize and deploy big projects using AWS API Gateway and AWS Lambda with Serverless Framework

Logo

Serverless Architecture Boilerplate serverless License: MIT Build Status

CI / CD Pipeline

Need a Codepipeline Structure to deploy your Serverless Project with Quality? See this repo!

Serverless Archictecture Boilerplate with Go?

Looking for boilerplates to organize big projects using AWS Lambda with Go? See this repo

Structure

.
β”œβ”€β”€ modules (modules folder)
β”‚Β Β  └── books (module / context)
β”‚Β Β      β”œβ”€β”€ endpoints (API endpoints)
β”‚Β Β      β”‚Β Β  β”œβ”€β”€ create.js
β”‚Β Β      β”‚Β Β  β”œβ”€β”€ delete.js
β”‚Β Β      β”‚Β Β  β”œβ”€β”€ read.js
β”‚Β Β      β”‚Β Β  └── update.js
β”‚Β Β      └── functions (workers / background functions)
β”‚Β Β          └── worker
β”‚Β Β              └── handler.js
β”œβ”€β”€ package.json
β”œβ”€β”€ serverless.yml (serverless config)
β”œβ”€β”€ handlers (functions config)
β”‚Β Β  β”œβ”€β”€ books-endpoints.yml (endpoints config)
β”‚Β Β  └── books-workers.yml (workers config)
β”œβ”€β”€ shared (shared components)
β”‚Β Β  └── lib (shared libraries)
β”‚Β Β      β”œβ”€β”€ dynamo.js
β”‚Β Β      β”œβ”€β”€ kinesis.js
β”‚Β Β      β”œβ”€β”€ lambda.js
β”‚Β Β      β”œβ”€β”€ parsers.js
β”‚Β Β      β”œβ”€β”€ sqs.js
β”‚Β Β      └── uuid.js
└── test (tests folder)
    └── unit (unit tests folder)
        β”œβ”€β”€ modules (unit tests for modules)
        β”‚Β Β  └── books
        └── shared (unit tests for shared components)
            └── lib (unit tests for libraries)
                β”œβ”€β”€ dynamo.test.js
                β”œβ”€β”€ kinesis.test.js
                β”œβ”€β”€ parsers.test.js
                β”œβ”€β”€ sqs.test.js
                └── uuid.test.js

Functions

HTTP Trigger Function (API Gateway)

functions:

  # API Endpoints
  books-register:
    handler: modules/books/endpoints/create.create #Path to function
    memorySize: 128 # Lambda Memory Limit
    timeout: 60 # Lambda Timeout
    events: 
      - http: # HTTP Trigger 
          path: services/books # API Endpoint
          method: post # HTTP Method

Cloudwatch Events Functions (Cron)

Lambda Schedule Docs

# Background Function
  books-consumer:
    handler: modules/books/functions/worker/handler.worker #Path to function
    events:
      - schedule: #Cloudwatch Event Trigger
        rate: cron(* * * * * *) # Cron Syntax 
        enabled: true # Trigger Enabled

Development environment

This boilerplate uses serverless-local plugin and some containers and plugins to emulate the AWS Resources

docker-compose up

The applications will start on http://localhost:3000

Dev Plugins

This boilerplate contains following plugins for local development:

Production environment

Deploy full services

serverless deploy -v

asciicast

Deploy a function

serverless deploy function -f books-consumer

Get function logs

serverless books-consumer -f bananinha -t

Clean All

serverless remove

Testing

Create Book

curl -X POST \
    -H "Content-Type: application/json" \
    -d '{"title": "American Gods", "author": "Neil Gaiman", "price": 10.00  }' \
    https://yur25zhqo0.execute-api.us-east-1.amazonaws.com/production/services/books -i

List Books

curl -X GET \
    https://yur25zhqo0.execute-api.us-east-1.amazonaws.com/production/services/books

asciicast

Detail Book

curl -X GET \
    https://yur25zhqo0.execute-api.us-east-1.amazonaws.com/production/services/books/456c9e8f-6c50-d656-dc69-dc828c42af65

Delete Book

curl -X DELETE \
    https://yur25zhqo0.execute-api.us-east-1.amazonaws.com/production/services/books/456c9e8f-6c50-d656-dc69-dc828c42af65 -i 

Update Book

curl -X PUT \
    -d '{"title": "updated modafoca"}' -H "Content-type: application/json" \
    https://eusrv4mci5.execute-api.us-east-1.amazonaws.com/production/services/books/bbafdb0c-ee6e-fca0-f224-ed534f5b7766 -i

asciicast

Custom and Environment Variables

Custom Items

Creating and Using custom variables to build dynamic name

custom:
  region: ${self:provider.region} 
  stage: ${opt:stage, self:provider.stage}
  prefix: ${self:custom.stage}-${self:service}
  process: ${self:custom.prefix}-process
  config: ${self:custom.prefix}-config
  dynamo-books: ${self:custom.prefix}-BooksCatalog
  sns-logs: ${self:custom.prefix}-trigger-logs 
  sqs-logs: ${self:custom.prefix}-messages-logs

Environment Variables

Building URL Resources using CloudFormation parameters and Custom Variables

  environment: # Global Environment variables
    DYNAMO_TABLE_BOOKS: ${self:custom.dynamo-books} # Reference to Custom Env
    SQS_QUEUE_URL: 'https://sqs.${self:provider.region}.amazonaws.com/#{AWS::AccountId}/${self:custom.sqs-logs}'
    REGION: ${self:custom.region}

Manage AWS Cloudformation with Serverless

IAM Roles

IAM Docs

  iamRoleStatements: # Permissions for all of your functions can be set here

  - Effect: Allow
    Action: # Gives permission to DynamoDB tables in a specific region
      - dynamodb:DescribeTable
      - dynamodb:Query
      - dynamodb:Scan
      - dynamodb:GetItem
      - dynamodb:PutItem
      - dynamodb:UpdateItem
      - dynamodb:DeleteItem
    Resource: "arn:aws:dynamodb:us-east-1:*:*"

  - Effect: Allow
    Action: # Gives permission to Lambda execution
      - lambda:InvokeFunction
      - lambda:InvokeAsync
    Resource: "*"

Manage Infrastructure Components - Docs

# Infrastrucure - Cloud Formation
resources:  # CloudFormation template syntax

  Resources:
    #DynamoDB Books Table
    BooksCatalog:
      Type: AWS::DynamoDB::Table # CloudFormation Pseudo Parameter Example
      Properties:
        TableName: ${self:custom.dynamo-books}
        AttributeDefinitions:
          - AttributeName: hashkey
            AttributeType: S
        KeySchema:
          - AttributeName: hashkey
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 2
          WriteCapacityUnits: 1

    # SQS Queue to Update DynamoDB
    BooksQueueExample:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: ${self:custom.sqs-logs}
        MessageRetentionPeriod: 1209600
        VisibilityTimeout: 60

More Repositories

1

eks-with-istio

🐳 πŸ“¦ πŸš€ - Terraform template for a production ready EKS Cluster and ISTIO Service Mesh
HCL
136
star
2

ecs-pipeline

☁️ 🐳 ⚑ πŸš€ Create environment and deployment pipelines to ECS Fargate with CodePipeline, CodeBuild and Github using Terraform
HCL
115
star
3

terraformando-eks

πŸš€ πŸ“¦ 🐳 codebase da sΓ©rie de videos Terraformando o EKS no Youtube
HCL
102
star
4

CintoDeUtilidadesDocker

My Docker templates repository 🐳 ☁️ 🐳
VCL
94
star
5

kubernetes-with-cri-o

πŸ“¦ πŸš€ πŸ“¦ - Kubernetes Cluster setup using CRI-O Runtime
Jinja
93
star
6

Kill-Router-

Ferramenta para quebrar senhas administrativas de roteadores Wireless, routers, switches e outras plataformas de gestão de serviços de rede autenticados.
Python
86
star
7

ecs-microservices-orchestration

☁️ 🐳 ⚑ πŸš€ πŸ“¦ Complete microservices orchestration on ECS on AWS using Terraform
HCL
76
star
8

aws-turn-off-my-account

πŸ“¦ πŸš€ πŸ“¦ Lambda stack to turn off and destroy all resources from your personal AWS Account to avoid billing surprises
Go
67
star
9

cncf-platform-stack

🐳 πŸ“¦ πŸš€ ⚑ Recursos da sΓ©rie de vΓ­deos sobre stack da CNCF
64
star
10

cassler

πŸ•·οΈ πŸ•·οΈ πŸ•·οΈ - Validate SSL Certificates around web
Go
60
star
11

kubedump

🐳 πŸ“¦ πŸš€ - Simple tool to dump and restore kubernetes resources
Go
49
star
12

slim-microservices

Exemplos da evolução da nossa API usados na série de Posts sobre Slim Framework no Medium.
PHP
42
star
13

serverless-pipeline

Pipeline to build, test and deploy Serverless Framework Projects with CodeBuild and CodePipeline on AWS using Terraform. ⚑ πŸš€ ⚑ πŸš€
HCL
40
star
14

kafka-stress

CLI Tool to Stress Apache Kafka Clusters
Go
38
star
15

serverless-architecture-boilerplate-go

πŸ“¦ ⚑ πŸš€ Boilerplate to organize and deploy big projects using AWS API Gateway and AWS Lambda with Serverless Framework, but using Go!
Go
38
star
16

envoy-proxy-examples

Use cases for Envoy Proxy vanilla
Dockerfile
31
star
17

istio-disaster-recovery

Go
29
star
18

rsmq-promise

Promise interface for RSMQ
JavaScript
28
star
19

aws-multi-region-disaster-recovery

πŸ”₯ πŸ”₯ πŸ”₯ - Example to explain how to implement minimal multi-region architecture on AWS with disaster recovery
HCL
24
star
20

eks-karpenter-autonomous-cluster

🐳 πŸ“¦ πŸš€ - Elastic Kubernetes Service fully managed using Karpenter Autoscaler, without Node Groups
HCL
23
star
21

kubernetes-kind-setup

πŸ“¦ 🐳 πŸ“¦ - Bootstrap for my Kubernetes Cluster local using Kind
Smarty
23
star
22

chip

πŸ“¦ 🐳 πŸš€ - Smart "dummy" mock for cloud native tests
Go
21
star
23

TorrentRSSDownloader

Script/Daemon que eu diz em Python para baixar todos os novos episΓ³dios de Game of Thrones por Torrent. Mas na verdade vocΓͺ pode utilizar em qualquer sΓ©rie ;) #NΓ£oSouResponsΓ‘velPeloUsoDessaParada
Python
21
star
24

eks-with-cilium

🐳 πŸ“¦ πŸš€ - Terraform template for a production ready EKS Cluster and Cilium Service Mesh and eBPF
HCL
20
star
25

linuxtips-curso-containers-aws

🐧 🐧 🐧 - Repositório Central do Curso de Containers na AWS. Materiais extras e guia do curso.
20
star
26

hacking-scripts-sandbox

Sandbox for my White/Gray Hat Tools
PHP
19
star
27

gin-chaos-monkey

🍸 🍸 🍸 - Chaos Monkey assalts middleware for Gin Gonic
Go
19
star
28

analise-identificao-urnas-eletronicas

R
19
star
29

nutrition-overengineering

🍞 πŸ” πŸ• πŸ₯ͺ πŸ₯š πŸ₯“ - Application to calc healthcare and nutrition metrics, but using the most over engineered as possible
Go
19
star
30

terraform-static-site-pipeline

Easy (🌴 🍺) and cheap (πŸ’Έ) way to deploy and scale frontend sites on AWS with Terraform 🌎
HCL
19
star
31

jmeter-grafana-influxdb

🐳 πŸ“¦ πŸ“ˆ πŸ“‰ πŸ“Š Loadtest Stack Automation with Jmeter
Dockerfile
18
star
32

boreal

REST interface for MySQL, MariaDB and Aurora servers running in containers! 🐳 ❄️
JavaScript
18
star
33

PythonBackupSystem

Rotinas de Backup Full e Diferencial feitas em Python #IndustriaFox
Python
17
star
34

jenkins-ecs-slaves

How to use ECS Cluster to build / deploy your applications with Jenkins Slaves
HCL
17
star
35

cloud-inventory

☁️ ☁️ ☁️ Simple tool to search tagged resources between all AWS resouces
Go
16
star
36

sonarqube-stack

πŸ“¦ 🐳 πŸ“¦ 🐳 Local and Kubernetes example to deploy Sonarqube server to CI
15
star
37

serverless-offline-sqs-esmq

Simple SQS and ESMQ plugin for Serverless Framework ⚑ ⚑
JavaScript
13
star
38

k8s-complete-stack

🐳 πŸ“¦ πŸš€ I'm just trying to create the entire Kubernetes ecosystem with CNCF projects kkkkk
HCL
13
star
39

cloud-native-microservice-boilerplate

πŸ“¦ 🐳 πŸš€ ⚑ Personal project boilerplate to start new cloud native microservices projects with Go quickly
Go
13
star
40

aws-vpc-best-pratices

Personal compilation for best pratices for VPC Network architectures on AWS to improve performance, high avalilability and security for your apps. ☁️
HCL
12
star
41

sigil

πŸšͺ πŸšͺ πŸšͺ - The Command Line of Doors - Just an "lsof" wrapper for lazy people
Go
12
star
42

atlantis-aws

Setup Atlantis on AWS to manage Terraform with GitOps
HCL
10
star
43

eks-terraform-orchestration

πŸ“¦ 🐳 πŸš€ Complete setup process to manage EKS cluster using Terraform
HCL
9
star
44

dotfiles

πŸ“ πŸ“‹ πŸ“Ž
Shell
9
star
45

micro-api

Personal boilerplate to bootstrap simple applications and microservices ⚑ ⚑ ⚑
JavaScript
9
star
46

pudim

Homenagem ao saudoso pudim.com.br rodando em containers. As vezes eu preciso de uma coisa nada a ver pra testar uns rolΓͺ aleatΓ³rio.
HTML
9
star
47

eks-graviton2

🐳 πŸ“¦ πŸš€ EKS Clusters for tests with Graviton2 Instances
HCL
8
star
48

elk-cluster

πŸ“Š πŸ“ˆ πŸ“‰ Elasticsearch Cluster provisioned with Terraform and Ansible
Python
8
star
49

indices-economicos

πŸ“ˆ πŸ“‰ πŸ“Š - Gerador de datasets de alguns indices econΓ΄micos utilizando crawlers.
Go
8
star
50

aws-multi-region-disaster-recovery-apps

πŸ”₯ πŸ”₯ πŸ”₯ - Apps to aws-multi-region-disaster-recovery example
Go
7
star
51

awswaf-production-automation

Complete provisioning and automation management for AWS WAF V1 Rules - Regional Mode
HCL
7
star
52

the-game

Perdi.
7
star
53

PPA-Repository-Debian

Simples Bash Script to add Ubuntu PPA Repository on Debian Distros.
Shell
6
star
54

roleta-russa

πŸ”« Roleta russa do bash πŸ”« Jogue em containers 🐳, ou nos servers de produção. Cada um com suas prioridades.
Shell
6
star
55

argo-rollouts-article

πŸ™ πŸ™ πŸ™ - Example files from argo-rollouts article
6
star
56

HDWipeTool

Tool desenhada por diversão para apagar HD's, pendrives e partiçáes a nível de tabelas de alocação e cópias de bit a bit de partiçáes nulas.
Python
6
star
57

topper

Lightweight Node.js framework to build fast microservices on TCP Servers. πŸ”Œ ⚑ πŸ”‹
JavaScript
6
star
58

kubernetes-cluster-ansible

🐳 πŸ“¦ πŸš€ Simple Kubernetes Cluster with Terraform and Ansible working with Dynamic Inventory 🐳
Python
6
star
59

take-my-hash

Crypto.js helper - for lazy people (like me) πŸ” πŸ”‘
JavaScript
5
star
60

aws-sre-redis-cluster

Terraform module to launch Redis Clusters on AWS using the best pratices by default to compliance, resiliency and high availability
HCL
5
star
61

VHostCreator

Script simples para automatizar a criação de Virtualhosts no Apache
Shell
5
star
62

personal-blog

πŸ“š πŸ“š πŸ“š - RepositΓ³rio dos meus posts pΓΊblicos
HTML
5
star
63

opentelemetry-java-autoconfigure

Educational example explaining how to use OpenTelemetry's auto-instrumentation with Java and Spring Boot.
Java
5
star
64

feedly

Backup for my Feedly OPML feed
5
star
65

hexagonal-golang-microservice

Hexagonal architecture implementation in Golang
Go
5
star
66

aws-msk-glue-kafka-setup

Terraform setup for MSK as Kafka Cluster and Glue as Schema Registry
HCL
5
star
67

linuxtips-curso-containers-ecs-cluster

🐧 🐧 🐧 - Repositório de um cluster de ECS EC2
HCL
5
star
68

load-balancing-algorithms

Repository for my load balancing algorithms and comparisons between most commons Load Balancers
Dockerfile
4
star
69

eks-strimzi-kafka

🐳 πŸ“¦ πŸš€ - Experimental kubernetes cluster to serve and manage high scale Kafka brokers using Strimzi Operator
HCL
4
star
70

system-design-examples

πŸ“– πŸ“– πŸ“– - Exercicios de System Design em PT-BR
Go
4
star
71

vulnwebsite

Vulnerable SQL Injection photoblog for labs
CSS
4
star
72

raj

My (indian) toolset of day a day. πŸ”§ πŸ”¨ πŸ”© πŸ“Ž
JavaScript
4
star
73

msfidelis

4
star
74

graylog-stack-swarm

Graylog Stack for Swarm Mode. :neckbeard: 🐳
4
star
75

DockerParaMaiores

Exemplos da talk "Docker Para Maiores" realizado na Superlogica Tecnologias
JavaScript
4
star
76

hapijs-demo

Exemplos da palestra sobre HapiJS
JavaScript
4
star
77

GDG-IntroducaoAosContainers

Material da palestra de Introdução a Containers com Docker ministrada via Hangout no GDG Cabreúva em São Paulo.
HTML
4
star
78

go-kafka-labs

Studies for event driven architecture using go
Go
4
star
79

linuxtips-curso-containers-vpc

🐧 🐧 🐧 - Repositório da aula sobre construção de VPCs do curso de Arquitetura de Containers na AWS
HCL
4
star
80

dynamodb-eventbridge-pipes-to-sqs

Educational example to explain how to setup EventBridge Pipes to sync DynamoDB new itens to SQS
HCL
4
star
81

k8s-kops-superguide

In Brazil, we call it "colinha dos brother". Simple guide to run Kops on any cloud provider.
3
star
82

nutrition

Simple application to calc healthcare and nutrition metrics
Go
3
star
83

nJontas

Chrome plugin to change all images on webpages for Jontas pictures
JavaScript
3
star
84

terraform

My Terraform templates. ☁️ 🌲 🌎 🌏 🌍 πŸ“ƒ πŸ“
HCL
3
star
85

aws-batch-fargate

Simple Proof of Concept to explain how to use AWS Batch Jobs with Terraform
HCL
3
star
86

silex-api-skeleton

API criada utilizando o microframework Silex com o ORM Doctrine no padrΓ£o MVC pra construção rΓ‘pida de API's para MVPs πŸš€ πŸ‘Ύ :octocat:
PHP
3
star
87

aws-serverless-analytics-poc

[PoC] Simple stack to create ETLs and Data Warehouses on AWS
HCL
3
star
88

AulaAWS-Superlogica

Códigos e exemplos dados na aula de Introdução a Amazon AWS no Superlógica Labs.
Shell
3
star
89

eks-argo-sharding-multicluster

HCL
3
star
90

rinhadebackend-go-write-behind

Codebase do meu projeto para a rinha de backend 2024 - O objetivo é explorar as possibilidades de otimização de uso de caching aplicando os patterns de Write-Behind, ou Lazy Writting.
Go
3
star
91

microservice-nadave-whois

Using this shit to implement microservices tests on containers. "NadavΓͺ" ⚑
JavaScript
2
star
92

react-jokenpo

Simple Jokenpo implementation with React Native
JavaScript
2
star
93

gke-terraform-cluster

Simple Kubernetes service on GCP with GKS and Terraform 🐳 🐳 🐳
HCL
2
star
94

indicadores-combustiveis-brasil

πŸ“ˆ πŸ“‰ πŸ“Š Gerador de datasets dos indicadores de preΓ§o de combustΓ­veis no Brasil
Python
2
star
95

fiber-cloud-native

☁️ 🐳 πŸ“¦ Cloud Native Boilerplate for Fiber Framework
Go
2
star
96

QueuesComNodeEDocker

Escalando e Consumindo Filas Assincronas com Docker e NodeJS
JavaScript
2
star
97

crypto-utils-php

Pacote de gerenciamento de criptografia para PHP
PHP
2
star
98

devops-vagrant-box

My DevOps Environment Provisioning
Shell
2
star
99

rabbitmq-cluster

🐰 🐰 🐰 Setup your own rabbitmq cluster
Go
2
star
100

cakephp-smarty

My Personal CakePHP Core
JavaScript
2
star