diff --git a/README.md b/README.md
index 5960a917e..52c76bab4 100644
--- a/README.md
+++ b/README.md
@@ -13,12 +13,14 @@ A collection of ready-to-deploy [Serverless Framework](https://github.com/server
Click to expand
-- [Getting Started](#getting-started)
-- [Examples](#examples)
-- [Community Examples](#community-examples)
-- [Contributing](#contributing)
- * [Adding example code](#adding-example-code)
- * [Adding a community example](#adding-a-community-example)
+- [Serverless Examples](#serverless-examples)
+ - [Table of Contents](#table-of-contents)
+ - [Getting Started](#getting-started)
+ - [Examples](#examples)
+ - [Community Examples](#community-examples)
+ - [Contributing](#contributing)
+ - [Adding example code](#adding-example-code)
+ - [Adding a community example](#adding-a-community-example)
@@ -47,6 +49,7 @@ serverless install -u https://github.com/serverless/examples/tree/master/folder-
| [Aws Golang Auth Examples](https://github.com/serverless/examples/tree/master/aws-golang-auth-examples)
These example shows how to run a Golang lambda with authentication | golang |
| [Aws Golang Dynamo Stream To Elasticsearch](https://github.com/serverless/examples/tree/master/aws-golang-dynamo-stream-to-elasticsearch)
This example deploys a DynamoDB Table, an Elasticsearch Node, and a lambda triggered off of a Dynamo Stream which updates an elasticsearch index with the data from the Dynamo Table | golang |
| [Aws Golang Http Get Post](https://github.com/serverless/examples/tree/master/aws-golang-http-get-post)
Example on Making Parameterized Get and Post Request with Golang | golang |
+| [Aws Golang Rest Api With Dynamodb](https://github.com/serverless/examples/tree/master/aws-golang-rest-api-with-dynamodb)
Serverless CRUD service exposing a REST HTTP interface | golang |
| [Aws Golang Simple Http Endpoint](https://github.com/serverless/examples/tree/master/aws-golang-simple-http-endpoint)
Example demonstrates how to setup a simple HTTP GET endpoint with golang | golang |
| [Aws Golang Stream Kinesis To Elasticsearch](https://github.com/serverless/examples/tree/master/aws-golang-stream-kinesis-to-elasticsearch)
Pull data from AWS Kinesis streams and forward to elasticsearch | golang |
| [Aws Alexa Skill](https://github.com/serverless/examples/tree/master/aws-node-alexa-skill)
This example demonstrates how to use an AWS Lambdas for your custom Alexa skill. | nodeJS |
@@ -56,6 +59,8 @@ serverless install -u https://github.com/serverless/examples/tree/master/folder-
| [Aws Node Dynamodb Backup](https://github.com/serverless/examples/tree/master/aws-node-dynamodb-backup)
Serverless DynamoDB changes backed up to S3 | nodeJS |
| [Aws Env Variables Encrypted In A File](https://github.com/serverless/examples/tree/master/aws-node-env-variables-encrypted-in-a-file)
Serverless example managing secrets in an encrypted file | nodeJS |
| [Aws Env Variables](https://github.com/serverless/examples/tree/master/aws-node-env-variables)
This example demonstrates how to use environment variables for AWS Lambdas. | nodeJS |
+| [Aws Node Express Api](https://github.com/serverless/examples/tree/master/aws-node-express-api) | nodeJS |
+| [Aws Node Express Dynamodb Api](https://github.com/serverless/examples/tree/master/aws-node-express-dynamodb-api) | nodeJS |
| [Aws Fetch File And Store In S3](https://github.com/serverless/examples/tree/master/aws-node-fetch-file-and-store-in-s3)
Fetch an image from remote source (URL) and then upload the image to a S3 bucket. | nodeJS |
| [Sfe Demo Leadcapture](https://github.com/serverless/examples/tree/master/aws-node-fullstack/backend) | nodeJS |
| [Frontend](https://github.com/serverless/examples/tree/master/aws-node-fullstack/frontend) | nodeJS |
@@ -71,6 +76,8 @@ serverless install -u https://github.com/serverless/examples/tree/master/folder-
| [Aws Node Puppeteer](https://github.com/serverless/examples/tree/master/aws-node-puppeteer)
When it comes to AWS Lambda function , they have their own limits as follows  So , When you try to use Puppeteer your deployment package size(unzipped) easily go's above 250 mb because When you install Puppeteer, it downloads a recent version of Chromium (~170MB Mac, ~282MB Linux, ~280MB Win) that is guaranteed to work with the API. | nodeJS |
| [Aws Node Rekognition Analysis S3 Image](https://github.com/serverless/examples/tree/master/aws-node-rekognition-analysis-s3-image)
Analyse an Image from an S3 Bucket with Amazon Rekognition | nodeJS |
| [Aws Node Restapi Mongodb](https://github.com/serverless/examples/tree/master/aws-node-rest-api-mongodb)
Serverless REST API with MongoDB using Mongoose and Bluebird | nodeJS |
+| [Aws Node Rest Api Typescript](https://github.com/serverless/examples/tree/master/aws-node-rest-api-typescript-simple) | nodeJS |
+| [Aws Node Typescript Rest Api](https://github.com/serverless/examples/tree/master/aws-node-rest-api-typescript)
This is simple REST API example for AWS Lambda By Serverless framwork with TypeScript and MongoDB Atlas. | nodeJS |
| [Aws Rest Api Offline](https://github.com/serverless/examples/tree/master/aws-node-rest-api-with-dynamodb-and-offline)
Serverless REST API with DynamoDB and offline support | nodeJS |
| [Aws Rest With Dynamodb](https://github.com/serverless/examples/tree/master/aws-node-rest-api-with-dynamodb)
Serverless CRUD service exposing a REST HTTP interface | nodeJS |
| [Aws Fetch File And Store In S3](https://github.com/serverless/examples/tree/master/aws-node-s3-file-replicator)
Fetch an image from remote source (URL) and then upload the image to a S3 bucket. | nodeJS |
@@ -86,11 +93,14 @@ serverless install -u https://github.com/serverless/examples/tree/master/folder-
| [Aws Node Simple Transcribe S3](https://github.com/serverless/examples/tree/master/aws-node-simple-transcribe-s3)
Example demonstrates how to setup a lambda function to transcribe audio file | nodeJS |
| [Aws Single Page App Via Cloudfront](https://github.com/serverless/examples/tree/master/aws-node-single-page-app-via-cloudfront)
Demonstrating how to deploy a Single Page Application with Serverless | nodeJS |
| [Serverless Single Page App Plugin](https://github.com/serverless/examples/tree/master/aws-node-single-page-app-via-cloudfront/serverless-single-page-app-plugin)
A plugin to simplify deploying Single Page Application using S3 and CloudFront | nodeJS |
+| [Aws Node Sqs Worker](https://github.com/serverless/examples/tree/master/aws-node-sqs-worker)
Serverless Framework Node SQS Producer-Consumer on AWS | nodeJS |
| [Aws Node Stripe Integration](https://github.com/serverless/examples/tree/master/aws-node-stripe-integration)
This example for Stripe integration using AWS Lambda and API Gateway. | nodeJS |
| [Aws Node Line Echo Bot](https://github.com/serverless/examples/tree/master/aws-node-telegram-echo-bot)
This is a simple echo bot on Telegram | nodeJS |
| [Aws Text Analysis Via Sns Post Processing](https://github.com/serverless/examples/tree/master/aws-node-text-analysis-via-sns-post-processing)
Example demonstrates how to setup a simple data processing pipeline | nodeJS |
| [Aws Node Twilio Send Text Message](https://github.com/serverless/examples/tree/master/aws-node-twilio-send-text-message)
Send a text message via twilio from aws lambda. [See live demo](http://twilio-serverless-example.surge.sh) | nodeJS |
| [Baddadjokesbot](https://github.com/serverless/examples/tree/master/aws-node-twitter-joke-bot) | nodeJS |
+| [Aws Node Typescript Apollo Lambda](https://github.com/serverless/examples/tree/master/aws-node-typescript-apollo-lambda)
Serverless example for apollo lambda | nodeJS |
+| [Aws Node Typescript Kinesis](https://github.com/serverless/examples/tree/master/aws-node-typescript-kinesis)
Serverless example using Kinesis with TypeScript | nodeJS |
| [Nest Serverless](https://github.com/serverless/examples/tree/master/aws-node-typescript-nest)
serverless app | nodeJS |
| [Typescript Example](https://github.com/serverless/examples/tree/master/aws-node-typescript-rest-api-with-dynamodb) | nodeJS |
| [Aws Node Typescript Sqs Standard](https://github.com/serverless/examples/tree/master/aws-node-typescript-sqs-standard)
Serverless example using Standard SQS with TypeScript | nodeJS |
@@ -99,6 +109,8 @@ serverless install -u https://github.com/serverless/examples/tree/master/folder-
| [Aws Nodejs Websockets Authorizers](https://github.com/serverless/examples/tree/master/aws-node-websockets-authorizers)
Simple example that demonstrates how to use authorizer functions with websocket events | nodeJS |
| [Aws Alexa Skill](https://github.com/serverless/examples/tree/master/aws-python-alexa-skill)
This example demonstrates how to use an AWS Lambdas for your custom Alexa skill. | python |
| [Aws Auth0 Api Gateway](https://github.com/serverless/examples/tree/master/aws-python-auth0-custom-authorizers-api)
Demonstration of protecting API gateway endpoints with auth0 | python |
+| [Aws Python Flask Api](https://github.com/serverless/examples/tree/master/aws-python-flask-api)
Example of a Python Flask API service with traditional Serverless Framework | python |
+| [Aws Python Flask Dynamodb Api](https://github.com/serverless/examples/tree/master/aws-python-flask-dynamodb-api)
Example of a Python Flask API service backed by DynamoDB with traditional Serverless Framework | python |
| [Aws Python Line Echo Bot](https://github.com/serverless/examples/tree/master/aws-python-line-echo-bot)
this is echo bot on LINE message | python |
| [Aws Python Pynamodb S3 Sigurl](https://github.com/serverless/examples/tree/master/aws-python-pynamodb-s3-sigurl)
Serverless signed uploader REST API using pynamodb, s3 generated events, custom log format, and DRY serverless.yml with custom section | python |
| [Aws Rest With Dynamodb](https://github.com/serverless/examples/tree/master/aws-python-rest-api-with-dynamodb)
Serverless CRUD service exposing a REST HTTP interface | python |
@@ -107,12 +119,21 @@ serverless install -u https://github.com/serverless/examples/tree/master/folder-
| [Aws Rest With Pynamodb](https://github.com/serverless/examples/tree/master/aws-python-rest-api-with-pynamodb)
Serverless CRUD service exposing a REST HTTP interface | python |
| [Aws Scheduled Cron](https://github.com/serverless/examples/tree/master/aws-python-scheduled-cron)
Example of creating a function that runs as a cron job using the serverless `schedule` event | python |
| [Aws Simple Http Endpoint](https://github.com/serverless/examples/tree/master/aws-python-simple-http-endpoint)
Example demonstrates how to setup a simple HTTP GET endpoint with python | python |
+| [Aws Python Sqs Worker](https://github.com/serverless/examples/tree/master/aws-python-sqs-worker)
Serverless Framework Python SQS Producer-Consumer on AWS | python |
| [Serverless Telegram Bot](https://github.com/serverless/examples/tree/master/aws-python-telegram-bot)
This example demonstrates how to setup an echo Telegram Bot using the Serverless Framework ⚡🤖 | python |
+| [Serverless Ruby Dynamodb Cron](https://github.com/serverless/examples/tree/master/aws-ruby-cron-with-dynamodb)
This is an example of creating a function that runs as a cron job using the serverless 'schedule' event. With the usage of the AWS Lambda function, it creates a record to the DynamoDB each and every 30 minutes. | ruby |
| [Aws Ruby Line Bot](https://github.com/serverless/examples/tree/master/aws-ruby-line-bot)
Example demonstrates how to setup a simple Line echo bot on AWS | ruby |
| [Aws Ruby Simple Http Endpoint](https://github.com/serverless/examples/tree/master/aws-ruby-simple-http-endpoint)
Example demonstrates how to setup a simple HTTP GET endpoint | ruby |
+| [Aws Ruby Sinatra Dynamodb Api](https://github.com/serverless/examples/tree/master/aws-ruby-sinatra-dynamodb-api)
Example of a Ruby Sinatra API service backed by DynamoDB with traditional Serverless Framework | ruby |
+| [Aws Ruby Step Functions Callback](https://github.com/serverless/examples/tree/master/aws-ruby-step-functions-with-callback)
Ruby example that make usage of AWS Step Functions with callback pattern, AWS Lambda, DynamoDB, Amazon Comprehend, API Gateway, and Step Functions flows | ruby |
+| [Serverless Ruby Sqs Dynamodb](https://github.com/serverless/examples/tree/master/aws-ruby-sqs-with-dynamodb)
A serverless ruby example that creates DynamoDB records with the usage of SQS, API Gateway, and AWS Lambda functions. | ruby |
+| [Aws Ruby Step Functions](https://github.com/serverless/examples/tree/master/aws-ruby-step-functions)
Ruby example that make usage of AWS Step Functions with AWS Lambda, DynamoDB and Step Functions flows. | ruby |
+| [Aws Ruby Step Functions Express Workflow](https://github.com/serverless/examples/tree/master/aws-ruby-step-functions-express)
Ruby example that make usage of AWS Step Functions Express Type with AWS Lambda, DynamoDB, Amazon SES, API Gateway, and Step Functions flows | ruby |
+| [Aws Rust Simple Http Endpoint](https://github.com/serverless/examples/tree/master/aws-rust-simple-http-endpoint)
Example demonstrates how to setup a simple HTTP GET endpoint with rust | nodeJS |
| [Azure Nodejs](https://github.com/serverless/examples/tree/master/azure-node-line-bot)
Azure Functions sample for the Serverless framework | nodeJS |
| [Azure Node Simple Http Endpoint](https://github.com/serverless/examples/tree/master/azure-node-simple-http-endpoint)
An example of making http endpoints with the Azure Functions Serverless Framework plugin | nodeJS |
| [Azure Nodejs](https://github.com/serverless/examples/tree/master/azure-node-telegram-bot)
Azure Functions sample for the Serverless framework | nodeJS |
+| [Service Bus Trigger Example](https://github.com/serverless/examples/tree/master/azure-node-typescript-servicebus-trigger-endpoint)
Serverless application for asset model creation | nodeJS |
| [Google Golang Simple Http Endpoint](https://github.com/serverless/examples/tree/master/google-golang-simple-http-endpoint)
Example demonstrates how to setup a simple HTTP GET endpoint with golang | golang |
| [Google Node Simple Http Endpoint](https://github.com/serverless/examples/tree/master/google-node-simple-http-endpoint)
An example of making http endpoints with the Google Cloud Functions Serverless Framework plugin. | nodeJS |
| [Gcp Node Typescript Simple](https://github.com/serverless/examples/tree/master/google-node-typescript-http-endpoint)
Simple HTTP example for GCP functions by Serverless framework with Typescript | nodeJS |
@@ -130,6 +151,7 @@ serverless install -u https://github.com/serverless/examples/tree/master/folder-
| [Openwhisk Python Simple Http Endpoint](https://github.com/serverless/examples/tree/master/openwhisk-python-simple-http-endpoint)
Example demonstrates how to setup a simple HTTP GET endpoint with OpenWhisk. | python |
| [Openwhisk Python Simple](https://github.com/serverless/examples/tree/master/openwhisk-python-simple)
Example demonstrates how to setup a simple Python function with OpenWhisk. | python |
| [Openwhisk Ruby Simple](https://github.com/serverless/examples/tree/master/openwhisk-ruby-simple)
Example demonstrates how to setup a simple Ruby function with OpenWhisk. | ruby |
+| [Openwhisk Rust Simple Http Endpoint](https://github.com/serverless/examples/tree/master/openwhisk-rust-simple-http-endpoint)
Example demonstrates how to setup a simple Rust function with OpenWhisk. | nodeJS |
| [Openwhisk Swift Package With Precompiled Binaries](https://github.com/serverless/examples/tree/master/openwhisk-swift-precompiled-binaries)
Swift packages and pre-compiled binaries on OpenWhisk. | swift |
| [Openwhisk Swift Scheduled Cron](https://github.com/serverless/examples/tree/master/openwhisk-swift-scheduled-cron)
Example of creating a Swift function that runs as a cron job using the serverless schedule event. | swift |
| [Openwhisk Swift Simple Http Endpoint](https://github.com/serverless/examples/tree/master/openwhisk-swift-simple-http-endpoint)
Example demonstrates how to setup a simple HTTP endpoint using Swift function with OpenWhisk. | swift |
@@ -160,10 +182,14 @@ serverless install -u https://github.com/author/project -n my-project
| **[Commenting Api](https://github.com/AyoubEd/serverless_typescript_graphQl_commentingService)**
A commenting api using Serverless Typescript GraphQl and Redis | [AyoubEd](http://github.com/AyoubEd) |
| **[Daily Instance Backups With Ami Rotation](https://github.com/AndrewFarley/AWSAutomatedDailyInstanceAMISnapshots)**
A simple Python application which scans through your entire AWS account for tagged instances, makes daily AMIs of them, and rotates their backups automatically | [AndrewFarley](http://github.com/AndrewFarley) |
| **[Demo Project For Serverless Migrate Plugin](https://github.com/EliuX/serverless-migrate-plugin/tree/master/example)**
An example about how to use migrations in your serverless project with serverless-migrate-plugin | [EliuX](http://github.com/EliuX) |
-| **[Dropbucket Serverless File Sharing](https://github.com/marksteele/drop-bucket)**
A serverless file sharing app powered by Cognito/S3/Lambda/API Gateway. Includes a React single-page app UI and virus scanning. | [marksteele](http://github.com/marksteele) |
+| **[Express Application With Lambda](https://github.com/HoseungJang/serverless-lambda-express-example)**
This example demonstrates how to build an express application for AWS Lambda based on serverless framework. | [HoseungJang](http://github.com/HoseungJang) |
+| **[File uploads using S3 presigned URLs](https://github.com/marchetti2/aws-node-serverless-upload-presigned-url)**
A Serverless photo upload service with API Gateway, S3 presigned URLs and Lambda. | [marchetti2](https://github.com/marchetti2) |
| **[Fotopia Serverless](https://github.com/mbudm/fotopia-serverless)**
A photo archive web app including API, storage and face detection using serverless framework | [mbudm](http://github.com/mbudm) |
+| **[Golive](https://github.com/adimoraret/golive/)**
Boilerplate to live stream using AWS MediaLive and MediaStore | [adimoraret](http://github.com/adimoraret) |
+| **[Http Headers Checks](https://github.com/authdog/http-headers-check)**
Serverless Application to check integrity of the headers of a given HTTP server | [authdog](http://github.com/authdog) |
| **[Json Serverless](https://github.com/pharindoko/json-serverless)**
A simple & cheap serverless REST API using [json-server](https://github.com/typicode/json-server) in combination with AWS Lambda / S3 and the serverless framework | [pharindoko](http://github.com/pharindoko) |
| **[Lambda Pubsub Via Sns Example](https://github.com/didil/serverless-lambda-sns-example)**
Example illustrating the flow: Lambda (publisher) => SNS => Lambda (consumer) | [didil](http://github.com/didil) |
+| **[Monorepo Typescript microservices](https://github.com/fargito/serverless-monorepo-microservices-template)**
An opinionated Serverless template with several Typescript microservices in a monorepo | [fargito](http://github.com/fargito) |
| **[Nietzsche](https://github.com/rpidanny/Nietzsche)**
A serverless application that fetches quotes from Goodreads and saves it to DynamoDB with example use cases using `Lambda`, `SNS`, `SQS`, `Step Functions`, `DynamoDB`, `API Gateway`, `CloudWatch` | [rpidanny](http://github.com/rpidanny) |
| **[Open Bot](https://github.com/open-bot/open-bot)**
An unoptionated Github bot driven by a configuration file in the repository | [open-bot](http://github.com/open-bot) |
| **[Personal Access Tokens Cron Check](https://github.com/madtrick/cfpat-audit)**
Audit for leaked PAT in your Contentful organization. How to use serverless as cronjobs to keep your Personal Access Tokens secure | [madtrick](http://github.com/madtrick) |
@@ -174,20 +200,24 @@ serverless install -u https://github.com/author/project -n my-project
| **[Sqs Worker With Aws Lambda And Cloudwatch Alarms](https://github.com/sbstjn/sqs-worker-serverless)**
Process messages stored in SQS with an [auto-scaled AWS Lambda worker](https://sbstjn.com/serverless-sqs-worker-with-aws-lambda.html) function. | [sbstjn](http://github.com/sbstjn) |
| **[Serverless + Lambda + Vpc + Nat + Redis](https://github.com/ittus/aws-lambda-vpc-nat-examples)**
Demo using API Gateway and Lambda with VPC and NAT to access Internet and AWS Resource | [ittus](http://github.com/ittus) |
| **[Serverless Analytics](https://github.com/sbstjn/serverless-analytics)**
Write your own Google Analytics clone and track website visitors serverless with API Gateway, Kinesis, Lambda, and DynamoDB. | [sbstjn](http://github.com/sbstjn) |
+| **[Serverless Appsync Offline Typescript With Circleci](https://github.com/daisuke-awaji/serverless-appsync-offline-typescript-template)**
A Serverless Framework template that allows you to launch an AppSync emulator locally and proceed with development. Lambda Function build by TypeScript/Webpack. | [daisuke-awaji](http://github.com/daisuke-awaji) |
| **[Serverless Architecture Boilerplate](https://github.com/msfidelis/serverless-architecture-boilerplate)**
Boilerplate to organize and deploy big projects using Serverless and CloudFormation on AWS | [msfidelis](http://github.com/msfidelis) |
| **[Serverless Cloudwatch Proxy](https://github.com/abbasdgr8/cloudwatch-proxy)**
Logging adapter that consumes log streams from AWS CloudWatch, streams them to other log destinations. Also capable of identying alerts and sending notifications via Slack/Email | [abbasdgr8](http://github.com/abbasdgr8) |
| **[Serverless Dashboard For Atom Editor](https://github.com/horike37/serverless-dashboard-for-atom)**
Atom editor package which allows you to deploy and visualize your serverless services with Serverless Framework on your editor. | [horike37](http://github.com/horike37) |
| **[Serverless Es6/7 Crud Api](https://github.com/AnomalyInnovations/serverless-stack-demo-api)**
[Serverless Stack](http://serverless-stack.com) examples of backend CRUD APIs (DynamoDB + Lambda + API Gateway + Cognito User Pool authorizer) for [React.js single-page app](http://demo.serverless-stack.com) | [AnomalyInnovations](http://github.com/AnomalyInnovations) |
| **[Serverless Gitlab Ci](https://github.com/bvincent1/serverless-gitlab-ci)**
Simple Gitlab CI template for automatic testing and deployments | [bvincent1](http://github.com/bvincent1) |
+| **[Serverless Image Labeller](https://github.com/nileshprasad137/serverless-image-labeller)**
Serverless image labelling using Rekognition, s3, DynamoDB. | [nileshprasad137](http://github.com/nileshprasad137) |
| **[Serverless Instagram Crawler](https://github.com/kimcoder/serverless-instagram-crawler)**
Instagram hashtag Crawler with Lambda & DynamoDB. | [kimcoder](http://github.com/kimcoder) |
| **[Serverless Kakao Bot](https://github.com/JisuPark/serverless-kakao-bot)**
Easy development for Kakaotalk Bot with Serverless | [JisuPark](http://github.com/JisuPark) |
| **[Serverless Lambda S3 Demonstration](https://github.com/johncmunson/serverless-lambda-s3)**
This project demonstrates how the Serverless Framework can be used to deploy a NodeJS Lambda function that responds to events in an S3 bucket. | [johncmunson](http://github.com/johncmunson) |
| **[Serverless Load Balancer](https://github.com/pharindoko/serverless-load-balancer)**
A sample that shows how to combine a load balancer with (vpc/subnet configuration) with a lambda. | [pharindoko](http://github.com/pharindoko) |
| **[Serverless Next.js Example](https://github.com/kimcoder/serverless-nextjs)**
Next.js example project for development & deploy. | [kimcoder](http://github.com/kimcoder) |
+| **[Serverless Python Twitch Eventsub To Discord Webhook On Aws](https://github.com/dylmye/aws-python-twitch-eventsub-to-discord-webhook)**
This template takes go-live events from Twitch EventSub, and publishes the events through a Discord webhook | [dylmye](http://github.com/dylmye) |
| **[Serverless Rds Log Sync S3](https://github.com/drocco007/serverless-aws-rds-logs-s3)**
Annotated exmaple of a periodic scheduled task to sync changed RDS log files to an S3 bucket. | [drocco007](http://github.com/drocco007) |
| **[Serverless Reactjs Universal Rendering Boilerplate](https://github.com/TylorShin/react-universal-in-serverless)**
ReactJS web app Starter kit does universal (isomorphic) rendering with Serverless | [TylorShin](http://github.com/TylorShin) |
| **[Serverless Sns Sqs Offline Example ](https://github.com/kenyipp/serverless-sns-sqs-offline-example)**
Minimal example of running serverless-offline with SQS and SNS in local environment. | [kenyipp](http://github.com/kenyipp) |
| **[Serverless Ssh Command](https://github.com/upgle/serverless-openwhisk-ssh)**
Example of executing ssh command with OpenWhisk | [upgle](http://github.com/upgle) |
+| **[Serverless Screenshot To S3](https://github.com/slaytr/aws-node-screenshot-to-s3)**
An example serverless stack which takes a screenshot using aws-chrome-lambda and puts it in s3. NodeJS. | [slaytr](http://github.com/slaytr) |
| **[Serverless Telegram Bot](https://github.com/jonatasbaldin/serverless-telegram-bot)**
This example demonstrates how to setup an echo Telegram Bot using the Serverless Framework ⚡🤖 | [jonatasbaldin](http://github.com/jonatasbaldin) |
| **[Serverless Ffmpeg](https://github.com/kvaggelakos/serverless-ffmpeg)**
Bucket event driven FFMPEG using serverless. Input bucket => Serverless ffmpeg => Output bucket. | [kvaggelakos](http://github.com/kvaggelakos) |
| **[Serverless Sns Api](https://github.com/eddielisc/serverless-sns-api)**
Build a SNS service on AWS, support backend API for SNS by device, by group and by user | [eddielisc](http://github.com/eddielisc) |
@@ -195,6 +225,7 @@ serverless install -u https://github.com/author/project -n my-project
| **[Serving Binary Files](https://github.com/thomastoye/serverless-binary-files-xlsx)**
Small example showing how to serve binary files using Serverless on AWS with the serverless-apigw-binary plugin, using generated Excel files as an example | [thomastoye](http://github.com/thomastoye) |
| **[Spiderless, Web Spider On Serverless](https://github.com/slashbit/spider-less)**
A web spider / scraper / website change detector built with Lambda, API Gateway, DynamoDB and SNS | [slashbit](http://github.com/slashbit) |
| **[Stack Overflow Monitor](https://github.com/picsoung/stackoverflowmonitor)**
Monitor Stack Overflow questions and post them in a Slack channel | [picsoung](http://github.com/picsoung) |
+| **[[Unly] Boilerplates Generator](https://github.com/UnlyEd/boilerplates-generator)**
A boilerplates generator, meant to help to quick-start Serverless (AWS Lambda/API GW) and OSS projects, using good defaults _(sentry for automated error handling, staging/prod environments, built-in support for env vars, jest support, babel/webpack)_, yet flexible to fit your needs. | [UnlyEd](http://github.com/UnlyEd) |
| **[Adoptable Pet Bot](https://github.com/lynnaloo/adoptable-pet-bot)**
Tweets adoptable pets using Serverless (Node.js) and AWS Lambda | [lynnaloo](http://github.com/lynnaloo) |
| **[Aws Mfa Enforce](https://github.com/Chan9390/aws-mfa-enforce)**
Serverless function to automate enforcement of Multi-Factor Authentication (MFA) to all AWS IAM users with access to AWS Management Console. | [Chan9390](http://github.com/Chan9390) |
| **[Aws Node Signed Uploads](https://github.com/kalinchernev/aws-node-signed-uploads)**
Upload files larger than 10MB with AWS Lambda and API Gateway. Can be developed and tested locally. | [kalinchernev](http://github.com/kalinchernev) |
@@ -253,6 +284,7 @@ serverless install -u https://github.com/author/project -n my-project
| **[Sls Form Mail](https://github.com/takahashim/sls-form-mail)**
Send SNS email from form data | [takahashim](http://github.com/takahashim) |
| **[Vanity Stargazer](https://github.com/silvermullet/vanity-stargazer)**
Github vanity-stargazer is a serverless application to handle posting Github new star gazers to Slack | [silvermullet](http://github.com/silvermullet) |
| **[Video Preview And Analysis Service](https://github.com/laardee/video-preview-and-analysis-service)**
An event-driven service that generates labels using Amazon Rekognition and creates preview GIF animation from a video file. | [laardee](http://github.com/laardee) |
+| **[Idempotent Serverless Applications Examples](https://github.com/Nsupyq/idempotent-serverless-functions)**
Examples of how to write idempotent serverless functions. | [Nsupyq](https://github.com/Nsupyq) |
## Contributing
diff --git a/aws-dotnet-rest-api-with-dynamodb/README.MD b/aws-dotnet-rest-api-with-dynamodb/README.MD
index 5411a11e3..ebfcbc382 100644
--- a/aws-dotnet-rest-api-with-dynamodb/README.MD
+++ b/aws-dotnet-rest-api-with-dynamodb/README.MD
@@ -4,6 +4,7 @@ description: 'Setup a REST API w/ DynamoDB using Dot Net Core 2.1'
framework: v1
platform: AWS
language: CSharp
+priority: 10
authorLink: 'https://github.com/samueleresca'
authorName: 'Samuele Resca'
authorAvatar: 'https://avatars0.githubusercontent.com/u/8921095?v=4&s=140'
@@ -41,4 +42,4 @@ npm run build
```
npm run deploy
-```
\ No newline at end of file
+```
diff --git a/aws-ffmpeg-layer/README.md b/aws-ffmpeg-layer/README.md
index 00145ff58..0f74fe493 100644
--- a/aws-ffmpeg-layer/README.md
+++ b/aws-ffmpeg-layer/README.md
@@ -4,6 +4,7 @@ description: 'AWS FFmepg Layer & a service using it to create GIFs'
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/tdhopper'
authorName: 'Timothy Hopper'
authorAvatar: 'https://avatars0.githubusercontent.com/u/611122?v=4&s=140'
diff --git a/aws-ffmpeg-layer/serverless.yml b/aws-ffmpeg-layer/serverless.yml
index abed728c3..ce5ce18e1 100644
--- a/aws-ffmpeg-layer/serverless.yml
+++ b/aws-ffmpeg-layer/serverless.yml
@@ -1,5 +1,5 @@
service: gifmaker
-frameworkVersion: ">=1.34.0 <2.0.0"
+frameworkVersion: ">=2.24.0"
provider:
name: aws
diff --git a/aws-golang-auth-examples/Makefile b/aws-golang-auth-examples/Makefile
index 355570e28..dbbdd178e 100644
--- a/aws-golang-auth-examples/Makefile
+++ b/aws-golang-auth-examples/Makefile
@@ -5,5 +5,5 @@ functions := $(shell find functions -name \*main.go | awk -F'/' '{print $$2}')
build: ## Build golang binaries
@for function in $(functions) ; do \
- env GOOS=linux go build -ldflags="-s -w" -o bin/$$function functions/$$function/main.go ; \
+ env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o bin/$$function functions/$$function/main.go ; \
done
diff --git a/aws-golang-auth-examples/README.md b/aws-golang-auth-examples/README.md
index 880d46a1e..6b7291a52 100644
--- a/aws-golang-auth-examples/README.md
+++ b/aws-golang-auth-examples/README.md
@@ -4,6 +4,7 @@ description: 'This example shows you how to setup auth in front of a AWS Lambda
framework: v1
platform: AWS
language: Go
+priority: 10
authorLink: 'https://github.com/srbry'
authorName: 'srbry'
authorAvatar: 'https://avatars0.githubusercontent.com/u/16936753?v=4&s=140'
diff --git a/aws-golang-dynamo-stream-to-elasticsearch/Makefile b/aws-golang-dynamo-stream-to-elasticsearch/Makefile
index 6e963045c..6cec1fc56 100644
--- a/aws-golang-dynamo-stream-to-elasticsearch/Makefile
+++ b/aws-golang-dynamo-stream-to-elasticsearch/Makefile
@@ -1,6 +1,6 @@
build:
dep ensure -v
- env GOOS=linux go build -ldflags="-s -w" -o bin/aws-golang-dynamo-stream-to-elasticsearch cmd/aws-golang-dynamo-stream-to-elasticsearch/main.go
+ env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o bin/aws-golang-dynamo-stream-to-elasticsearch cmd/aws-golang-dynamo-stream-to-elasticsearch/main.go
.PHONY: clean
clean:
diff --git a/aws-golang-dynamo-stream-to-elasticsearch/README.md b/aws-golang-dynamo-stream-to-elasticsearch/README.md
index 945e812ed..49bc8afb8 100644
--- a/aws-golang-dynamo-stream-to-elasticsearch/README.md
+++ b/aws-golang-dynamo-stream-to-elasticsearch/README.md
@@ -4,6 +4,7 @@ description: 'Stream data from DynamoDB to Elasticsearch'
framework: v1
platform: AWS
language: Go
+priority: 10
authorLink: 'https://github.com/jalie'
authorName: 'Jan Liesendahl'
authorAvatar: 'https://avatars0.githubusercontent.com/u/548657?v=4&s=140'
@@ -73,4 +74,4 @@ e.g. with ip restriction:
IpAddress:
aws:sourceIp:
- "123.123.123.123"
-```
\ No newline at end of file
+```
diff --git a/aws-golang-dynamo-stream-to-elasticsearch/serverless.yml b/aws-golang-dynamo-stream-to-elasticsearch/serverless.yml
index 90b1130d3..19487f294 100644
--- a/aws-golang-dynamo-stream-to-elasticsearch/serverless.yml
+++ b/aws-golang-dynamo-stream-to-elasticsearch/serverless.yml
@@ -6,33 +6,34 @@ provider:
environment:
ELASTICSEARCH_URL:
Fn::GetAtt: ["PuppySearch", "DomainEndpoint"]
-
- iamRoleStatements:
- - Effect: Allow
- Action:
- - 'dynamodb:ListTables'
- - 'dynamodb:DescribeTable'
- - 'dynamodb:DescribeStream'
- - 'dynamodb:ListStreams'
- - 'dynamodb:GetShardIterator'
- - 'dynamodb:BatchGetItem'
- - 'dynamodb:GetItem'
- - 'dynamodb:Query'
- - 'dynamodb:Scan'
- - 'dynamodb:DescribeReservedCapacity'
- - 'dynamodb:DescribeReservedCapacityOfferings'
- - 'dynamodb:GetRecords'
- Resource:
- - { "Fn::GetAtt": ["PuppyDemo", "Arn"] }
- - Effect: Allow
- Action:
- - es:ESHttpPost
- - es:ESHttpPut
- - es:ESHttpDelete
- - es:ESHttpGet
- Resource:
- - { "Fn::GetAtt": ["PuppySearch", "DomainArn"] }
- - { "Fn::Join": ["", ["Fn::GetAtt": ["PuppySearch", "DomainArn"], "/*"]] }
+ iam:
+ role:
+ statements:
+ - Effect: Allow
+ Action:
+ - 'dynamodb:ListTables'
+ - 'dynamodb:DescribeTable'
+ - 'dynamodb:DescribeStream'
+ - 'dynamodb:ListStreams'
+ - 'dynamodb:GetShardIterator'
+ - 'dynamodb:BatchGetItem'
+ - 'dynamodb:GetItem'
+ - 'dynamodb:Query'
+ - 'dynamodb:Scan'
+ - 'dynamodb:DescribeReservedCapacity'
+ - 'dynamodb:DescribeReservedCapacityOfferings'
+ - 'dynamodb:GetRecords'
+ Resource:
+ - { "Fn::GetAtt": ["PuppyDemo", "Arn"] }
+ - Effect: Allow
+ Action:
+ - es:ESHttpPost
+ - es:ESHttpPut
+ - es:ESHttpDelete
+ - es:ESHttpGet
+ Resource:
+ - { "Fn::GetAtt": ["PuppySearch", "DomainArn"] }
+ - { "Fn::Join": ["", ["Fn::GetAtt": ["PuppySearch", "DomainArn"], "/*"]] }
package:
exclude:
diff --git a/aws-golang-googlemap/Makefile b/aws-golang-googlemap/Makefile
index c7403e612..d39c6068a 100644
--- a/aws-golang-googlemap/Makefile
+++ b/aws-golang-googlemap/Makefile
@@ -2,10 +2,10 @@
build:
dep ensure -v
- env GOOS=linux go build -ldflags="-s -w" -o bin/getgeolocation getgeolocation/main.go
- env GOOS=linux go build -ldflags="-s -w" -o bin/getsearchlocation getsearchlocation/main.go
- env GOOS=linux go build -ldflags="-s -w" -o bin/getnearbylocation getnearbylocation/main.go
- env GOOS=linux go build -ldflags="-s -w" -o bin/getgeodetail getgeodetail/main.go
+ env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o bin/getgeolocation getgeolocation/main.go
+ env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o bin/getsearchlocation getsearchlocation/main.go
+ env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o bin/getnearbylocation getnearbylocation/main.go
+ env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o bin/getgeodetail getgeodetail/main.go
clean:
rm -rf ./bin ./vendor Gopkg.lock
diff --git a/aws-golang-googlemap/README.md b/aws-golang-googlemap/README.md
index d2397db3f..b85d3aa0d 100644
--- a/aws-golang-googlemap/README.md
+++ b/aws-golang-googlemap/README.md
@@ -4,6 +4,7 @@ description: 'Serverless example using golang to hit google map api'
framework: v1
platform: AWS
language: Go
+priority: 10
authorLink: 'https://github.com/pramonow'
authorName: 'Pramono Winata'
authorAvatar: 'https://avatars0.githubusercontent.com/u/28787057?v=4&s=140'
@@ -31,4 +32,4 @@ There are three endpoint provided:
request:
parameters:
querystrings:
- placeid: true
\ No newline at end of file
+ placeid: true
diff --git a/aws-golang-googlemap/serverless.yml b/aws-golang-googlemap/serverless.yml
index 9ed1b7a89..580c38543 100644
--- a/aws-golang-googlemap/serverless.yml
+++ b/aws-golang-googlemap/serverless.yml
@@ -16,7 +16,7 @@ service: gomapservice # NOTE: update this with your service name
# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"
-frameworkVersion: ">=1.28.0 <2.0.0"
+frameworkVersion: ">=2.24.0"
provider:
name: aws
@@ -29,20 +29,22 @@ provider:
region: ap-southeast-1
# you can add statements to the Lambda function's IAM Role here
-# iamRoleStatements:
-# - Effect: "Allow"
-# Action:
-# - "s3:ListBucket"
-# Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] }
-# - Effect: "Allow"
-# Action:
-# - "s3:PutObject"
-# Resource:
-# Fn::Join:
-# - ""
-# - - "arn:aws:s3:::"
-# - "Ref" : "ServerlessDeploymentBucket"
-# - "/*"
+# iam:
+# role:
+# statements:
+# - Effect: "Allow"
+# Action:
+# - "s3:ListBucket"
+# Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] }
+# - Effect: "Allow"
+# Action:
+# - "s3:PutObject"
+# Resource:
+# Fn::Join:
+# - ""
+# - - "arn:aws:s3:::"
+# - "Ref" : "ServerlessDeploymentBucket"
+# - "/*"
# you can define service wide environment variables here
# environment:
diff --git a/aws-golang-http-get-post/Makefile b/aws-golang-http-get-post/Makefile
index 52907b59f..25765463a 100644
--- a/aws-golang-http-get-post/Makefile
+++ b/aws-golang-http-get-post/Makefile
@@ -1,10 +1,9 @@
.PHONY: build clean deploy
build:
- dep ensure -v
- env GOOS=linux go build -ldflags="-s -w" -o bin/getBin getFolder/getExample.go
- env GOOS=linux go build -ldflags="-s -w" -o bin/postBin postFolder/postExample.go
- env GOOS=linux go build -ldflags="-s -w" -o bin/getQueryBin getFolder/getQueryExample.go
+ cd getFolder && env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o ../bin/getBin getExample.go && cd ..
+ cd getFolder && env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o ../bin/getQueryBin getQueryExample.go && cd ..
+ cd postFolder && env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o ../bin/postBin ./postExample.go && cd ..
clean:
rm -rf ./bin ./vendor Gopkg.lock
diff --git a/aws-golang-http-get-post/README.md b/aws-golang-http-get-post/README.md
index bc7e48b16..adba787ac 100644
--- a/aws-golang-http-get-post/README.md
+++ b/aws-golang-http-get-post/README.md
@@ -4,6 +4,7 @@ description: 'Boilerplate code for Golang with GET and POST example'
framework: v1
platform: AWS
language: Go
+priority: 10
authorLink: 'https://github.com/pramonow'
authorName: 'Pramono Winata'
authorAvatar: 'https://avatars0.githubusercontent.com/u/28787057?v=4&s=140'
diff --git a/aws-golang-http-get-post/getFolder/go.mod b/aws-golang-http-get-post/getFolder/go.mod
new file mode 100644
index 000000000..01c7d2981
--- /dev/null
+++ b/aws-golang-http-get-post/getFolder/go.mod
@@ -0,0 +1,5 @@
+module getFolder
+
+go 1.17
+
+require github.com/aws/aws-lambda-go v1.26.0
diff --git a/aws-golang-http-get-post/getFolder/go.sum b/aws-golang-http-get-post/getFolder/go.sum
new file mode 100644
index 000000000..0425482bd
--- /dev/null
+++ b/aws-golang-http-get-post/getFolder/go.sum
@@ -0,0 +1,17 @@
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/aws/aws-lambda-go v1.26.0 h1:6ujqBpYF7tdZcBvPIccs98SpeGfrt/UOVEiexfNIdHA=
+github.com/aws/aws-lambda-go v1.26.0/go.mod h1:jJmlefzPfGnckuHdXX7/80O3BvUUi12XOkbv4w9SGLU=
+github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/aws-golang-http-get-post/postFolder/go.mod b/aws-golang-http-get-post/postFolder/go.mod
new file mode 100644
index 000000000..444fa9671
--- /dev/null
+++ b/aws-golang-http-get-post/postFolder/go.mod
@@ -0,0 +1,5 @@
+module postFolder
+
+go 1.17
+
+require github.com/aws/aws-lambda-go v1.26.0
diff --git a/aws-golang-http-get-post/postFolder/go.sum b/aws-golang-http-get-post/postFolder/go.sum
new file mode 100644
index 000000000..0425482bd
--- /dev/null
+++ b/aws-golang-http-get-post/postFolder/go.sum
@@ -0,0 +1,17 @@
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/aws/aws-lambda-go v1.26.0 h1:6ujqBpYF7tdZcBvPIccs98SpeGfrt/UOVEiexfNIdHA=
+github.com/aws/aws-lambda-go v1.26.0/go.mod h1:jJmlefzPfGnckuHdXX7/80O3BvUUi12XOkbv4w9SGLU=
+github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/aws-golang-http-get-post/serverless.yml b/aws-golang-http-get-post/serverless.yml
index a98976254..060c867ef 100644
--- a/aws-golang-http-get-post/serverless.yml
+++ b/aws-golang-http-get-post/serverless.yml
@@ -16,7 +16,7 @@ service: goservice # NOTE: update this with your service name
# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"
-frameworkVersion: ">=1.28.0 <2.0.0"
+frameworkVersion: ">=2.24.0"
provider:
name: aws
@@ -26,21 +26,24 @@ provider:
# stage: dev
# region: us-east-1
+
# you can add statements to the Lambda function's IAM Role here
-# iamRoleStatements:
-# - Effect: "Allow"
-# Action:
-# - "s3:ListBucket"
-# Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] }
-# - Effect: "Allow"
-# Action:
-# - "s3:PutObject"
-# Resource:
-# Fn::Join:
-# - ""
-# - - "arn:aws:s3:::"
-# - "Ref" : "ServerlessDeploymentBucket"
-# - "/*"
+# iam:
+# role:
+# statements:
+# - Effect: "Allow"
+# Action:
+# - "s3:ListBucket"
+# Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] }
+# - Effect: "Allow"
+# Action:
+# - "s3:PutObject"
+# Resource:
+# Fn::Join:
+# - ""
+# - - "arn:aws:s3:::"
+# - "Ref" : "ServerlessDeploymentBucket"
+# - "/*"
# you can define service wide environment variables here
# environment:
diff --git a/aws-golang-rest-api-with-dynamodb/.gitignore b/aws-golang-rest-api-with-dynamodb/.gitignore
new file mode 100644
index 000000000..e6ed61c6f
--- /dev/null
+++ b/aws-golang-rest-api-with-dynamodb/.gitignore
@@ -0,0 +1,20 @@
+.serverless
+bin
+*.pyc
+*.pyo
+
+# Binaries for programs and plugins
+*.exe
+*.exe~
+*.dll
+*.so
+*.dylib
+
+# Test binary, built with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+# Dependency directories (remove the comment below to include it)
+# vendor/
diff --git a/aws-golang-rest-api-with-dynamodb/Makefile b/aws-golang-rest-api-with-dynamodb/Makefile
new file mode 100644
index 000000000..b0e7a78b6
--- /dev/null
+++ b/aws-golang-rest-api-with-dynamodb/Makefile
@@ -0,0 +1,21 @@
+.PHONY: build clean deploy
+
+build:
+ env GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o bin/create todos/create.go
+ env GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o bin/delete todos/delete.go
+ env GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o bin/get todos/get.go
+ env GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o bin/list todos/list.go
+ env GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o bin/update todos/update.go
+
+clean:
+ rm -rf ./bin ./vendor Gopkg.lock
+
+deploy: clean build
+ sls deploy --verbose
+
+format:
+ gofmt -w todos/create.go
+ gofmt -w todos/delete.go
+ gofmt -w todos/get.go
+ gofmt -w todos/list.go
+ gofmt -w todos/update.go
diff --git a/aws-golang-rest-api-with-dynamodb/README.md b/aws-golang-rest-api-with-dynamodb/README.md
new file mode 100644
index 000000000..1ed9b68bf
--- /dev/null
+++ b/aws-golang-rest-api-with-dynamodb/README.md
@@ -0,0 +1,73 @@
+
+# aws-golang-rest-api-with-dynamodb
+
+Build & Deploy
+```
+make deploy
+```
+
+# CRUD Operations
+
+## Create
+
+```
+curl --request POST \
+ --url https://fz3n8nstdf.execute-api.us-east-1.amazonaws.com/dev/todos \
+ --header 'Content-Type: application/json' \
+ --data '{
+ "Title": "Walk the Dog",
+ "Details": "Complete before 11am"
+}'
+
+curl --request POST \
+ --url https://fz3n8nstdf.execute-api.us-east-1.amazonaws.com/dev/todos \
+ --header 'Content-Type: application/json' \
+ --data '{
+ "Title": "Mow the Lawn",
+ "Details": "Remember to buy gas"
+}'
+```
+
+## Read
+
+```
+curl --request GET \
+ --url https://fz3n8nstdf.execute-api.us-east-1.amazonaws.com/dev/todos/{id}
+```
+
+## Update
+
+```
+curl --request PUT \
+ --url https://fz3n8nstdf.execute-api.us-east-1.amazonaws.com/dev/todos/0d2263b7-c62d-4df6-8503-bb16ee8dd81 \
+ --header 'Content-Type: application/json' \
+ --data '{
+ "title": "Updated title",
+ "details": "Updated details"
+}'
+```
+
+## List
+
+```
+curl --request GET \
+ --url https://fz3n8nstdf.execute-api.us-east-1.amazonaws.com/dev/todos
+```
+
+
+## Delete
+
+```
+curl --request DELETE \
+ --url https://fz3n8nstdf.execute-api.us-east-1.amazonaws.com/dev/todos/0d2263b7-c62d-4df6-8503-bb16ee8dd81
+```
diff --git a/aws-golang-rest-api-with-dynamodb/go.mod b/aws-golang-rest-api-with-dynamodb/go.mod
new file mode 100644
index 000000000..8f38365ba
--- /dev/null
+++ b/aws-golang-rest-api-with-dynamodb/go.mod
@@ -0,0 +1,9 @@
+module github.com/serverless/examples/aws-golang-rest-api-with-dynamodb
+
+go 1.15
+
+require (
+ github.com/aws/aws-lambda-go v1.22.0
+ github.com/aws/aws-sdk-go v1.37.1 // indirect
+ github.com/google/uuid v1.2.0 // indirect
+)
diff --git a/aws-golang-rest-api-with-dynamodb/go.sum b/aws-golang-rest-api-with-dynamodb/go.sum
new file mode 100644
index 000000000..f4e0f8a8d
--- /dev/null
+++ b/aws-golang-rest-api-with-dynamodb/go.sum
@@ -0,0 +1,36 @@
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/aws/aws-lambda-go v1.22.0 h1:X7BKqIdfoJcbsEIi+Lrt5YjX1HnZexIbNWOQgkYKgfE=
+github.com/aws/aws-lambda-go v1.22.0/go.mod h1:jJmlefzPfGnckuHdXX7/80O3BvUUi12XOkbv4w9SGLU=
+github.com/aws/aws-sdk-go v1.37.1 h1:BTHmuN+gzhxkvU9sac2tZvaY0gV9ihbHw+KxZOecYvY=
+github.com/aws/aws-sdk-go v1.37.1/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
+github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
+github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
+github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
+github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/aws-golang-rest-api-with-dynamodb/package.json b/aws-golang-rest-api-with-dynamodb/package.json
new file mode 100644
index 000000000..aab92227d
--- /dev/null
+++ b/aws-golang-rest-api-with-dynamodb/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "aws-golang-rest-api-with-dynamodb",
+ "version": "1.0.0",
+ "description": "Serverless CRUD service exposing a REST HTTP interface",
+ "author": "",
+ "license": "MIT"
+ }
diff --git a/aws-golang-rest-api-with-dynamodb/serverless.yml b/aws-golang-rest-api-with-dynamodb/serverless.yml
new file mode 100644
index 000000000..099a46dcb
--- /dev/null
+++ b/aws-golang-rest-api-with-dynamodb/serverless.yml
@@ -0,0 +1,97 @@
+app: aws-golang-rest-api-with-dynamodb
+service: aws-golang-rest-api-with-dynamodb
+
+frameworkVersion: ">=2.24.0"
+
+provider:
+ name: aws
+ runtime: go1.x
+ environment:
+ DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}
+ iam:
+ role:
+ statements:
+ - Effect: Allow
+ Action:
+ - dynamodb:Query
+ - dynamodb:Scan
+ - dynamodb:GetItem
+ - dynamodb:PutItem
+ - dynamodb:UpdateItem
+ - dynamodb:DeleteItem
+ Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
+
+functions:
+ create:
+ handler: bin/create
+ package:
+ include:
+ - ./bin/create
+ events:
+ - http:
+ path: todos
+ method: post
+ cors: true
+
+ list:
+ handler: bin/list
+ package:
+ include:
+ - ./bin/list
+ events:
+ - http:
+ path: todos
+ method: get
+ cors: true
+
+ get:
+ handler: bin/get
+ package:
+ include:
+ - ./bin/get
+ events:
+ - http:
+ path: todos/{id}
+ method: get
+ cors: true
+
+ update:
+ handler: bin/update
+ package:
+ include:
+ - ./bin/update
+ events:
+ - http:
+ path: todos/{id}
+ method: put
+ cors: true
+
+ delete:
+ handler: bin/delete
+ package:
+ include:
+ - ./bin/deleteBin
+ events:
+ - http:
+ path: todos/{id}
+ method: delete
+ cors: true
+
+resources:
+ Resources:
+ TodosDynamoDbTable:
+ Type: 'AWS::DynamoDB::Table'
+ DeletionPolicy: Retain
+ Properties:
+ AttributeDefinitions:
+ -
+ AttributeName: id
+ AttributeType: S
+ KeySchema:
+ -
+ AttributeName: id
+ KeyType: HASH
+ ProvisionedThroughput:
+ ReadCapacityUnits: 1
+ WriteCapacityUnits: 1
+ TableName: ${self:provider.environment.DYNAMODB_TABLE}
diff --git a/aws-golang-rest-api-with-dynamodb/todos/create.go b/aws-golang-rest-api-with-dynamodb/todos/create.go
new file mode 100644
index 000000000..60eb4339a
--- /dev/null
+++ b/aws-golang-rest-api-with-dynamodb/todos/create.go
@@ -0,0 +1,90 @@
+package main
+
+import (
+ "github.com/aws/aws-lambda-go/events"
+ "github.com/aws/aws-lambda-go/lambda"
+ "github.com/aws/aws-sdk-go/aws"
+ "github.com/aws/aws-sdk-go/aws/session"
+ "github.com/aws/aws-sdk-go/service/dynamodb"
+ "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
+ "github.com/google/uuid"
+
+ "encoding/json"
+ "fmt"
+ "os"
+)
+
+type Item struct {
+ Id string `json:"id,omitempty"`
+ Title string `json:"title"`
+ Details string `json:"details"`
+}
+
+func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
+
+ // Creating session for client
+ sess := session.Must(session.NewSessionWithOptions(session.Options{
+ SharedConfigState: session.SharedConfigEnable,
+ }))
+
+ // Create DynamoDB client
+ svc := dynamodb.New(sess)
+
+ // New uuid for item id
+ itemUuid := uuid.New().String()
+
+ fmt.Println("Generated new item uuid:", itemUuid)
+
+ // Unmarshal to Item to access object properties
+ itemString := request.Body
+ itemStruct := Item{}
+ json.Unmarshal([]byte(itemString), &itemStruct)
+
+ if itemStruct.Title == "" {
+ return events.APIGatewayProxyResponse{StatusCode: 400}, nil
+ }
+
+ // Create new item of type item
+ item := Item{
+ Id: itemUuid,
+ Title: itemStruct.Title,
+ Details: itemStruct.Details,
+ }
+
+ // Marshal to dynamobb item
+ av, err := dynamodbattribute.MarshalMap(item)
+ if err != nil {
+ fmt.Println("Error marshalling item: ", err.Error())
+ return events.APIGatewayProxyResponse{StatusCode: 500}, nil
+ }
+
+ tableName := os.Getenv("DYNAMODB_TABLE")
+
+ // Build put item input
+ fmt.Println("Putting item: %v", av)
+ input := &dynamodb.PutItemInput{
+ Item: av,
+ TableName: aws.String(tableName),
+ }
+
+ // PutItem request
+ _, err = svc.PutItem(input)
+
+ // Checking for errors, return error
+ if err != nil {
+ fmt.Println("Got error calling PutItem: ", err.Error())
+ return events.APIGatewayProxyResponse{StatusCode: 500}, nil
+ }
+
+ // Marshal item to return
+ itemMarshalled, err := json.Marshal(item)
+
+ fmt.Println("Returning item: ", string(itemMarshalled))
+
+ //Returning response with AWS Lambda Proxy Response
+ return events.APIGatewayProxyResponse{Body: string(itemMarshalled), StatusCode: 200}, nil
+}
+
+func main() {
+ lambda.Start(Handler)
+}
diff --git a/aws-golang-rest-api-with-dynamodb/todos/delete.go b/aws-golang-rest-api-with-dynamodb/todos/delete.go
new file mode 100644
index 000000000..e67e6663f
--- /dev/null
+++ b/aws-golang-rest-api-with-dynamodb/todos/delete.go
@@ -0,0 +1,55 @@
+package main
+
+import (
+ "github.com/aws/aws-lambda-go/events"
+ "github.com/aws/aws-lambda-go/lambda"
+ "github.com/aws/aws-sdk-go/aws"
+ "github.com/aws/aws-sdk-go/aws/session"
+ "github.com/aws/aws-sdk-go/service/dynamodb"
+
+ "fmt"
+ "os"
+)
+
+type Item struct {
+ Id string `json:"id,omitempty"`
+ Title string `json:"title"`
+ Details string `json:"details"`
+}
+
+func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
+
+ // Creating session for client
+ sess := session.Must(session.NewSessionWithOptions(session.Options{
+ SharedConfigState: session.SharedConfigEnable,
+ }))
+
+ // Create DynamoDB client
+ svc := dynamodb.New(sess)
+
+ pathParamId := request.PathParameters["id"]
+
+ input := &dynamodb.DeleteItemInput{
+ Key: map[string]*dynamodb.AttributeValue{
+ "id": {
+ S: aws.String(pathParamId),
+ },
+ },
+ TableName: aws.String(os.Getenv("DYNAMODB_TABLE")),
+ }
+
+ // DeleteItem request
+ _, err := svc.DeleteItem(input)
+
+ // Checking for errors, return error
+ if err != nil {
+ fmt.Println("Got error calling DeleteItem: ", err.Error())
+ return events.APIGatewayProxyResponse{StatusCode: 500}, nil
+ }
+
+ return events.APIGatewayProxyResponse{StatusCode: 204}, nil
+}
+
+func main() {
+ lambda.Start(Handler)
+}
diff --git a/aws-golang-rest-api-with-dynamodb/todos/get.go b/aws-golang-rest-api-with-dynamodb/todos/get.go
new file mode 100644
index 000000000..8d9f66bbd
--- /dev/null
+++ b/aws-golang-rest-api-with-dynamodb/todos/get.go
@@ -0,0 +1,79 @@
+package main
+
+import (
+ "github.com/aws/aws-lambda-go/events"
+ "github.com/aws/aws-lambda-go/lambda"
+ "github.com/aws/aws-sdk-go/aws"
+ "github.com/aws/aws-sdk-go/aws/session"
+ "github.com/aws/aws-sdk-go/service/dynamodb"
+ "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
+
+ "encoding/json"
+ "fmt"
+ "os"
+)
+
+type Item struct {
+ Id string `json:"id,omitempty"`
+ Title string `json:"title"`
+ Details string `json:"details"`
+}
+
+func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
+
+ // Creating session for client
+ sess := session.Must(session.NewSessionWithOptions(session.Options{
+ SharedConfigState: session.SharedConfigEnable,
+ }))
+
+ // Create DynamoDB client
+ svc := dynamodb.New(sess)
+
+ // Getting id from path parameters
+ pathParamId := request.PathParameters["id"]
+
+ fmt.Println("Derived pathParamId from path params: ", pathParamId)
+
+ // GetItem request
+ result, err := svc.GetItem(&dynamodb.GetItemInput{
+ TableName: aws.String(os.Getenv("DYNAMODB_TABLE")),
+ Key: map[string]*dynamodb.AttributeValue{
+ "id": {
+ S: aws.String(pathParamId),
+ },
+ },
+ })
+
+ // Checking for errors, return error
+ if err != nil {
+ fmt.Println(err.Error())
+ return events.APIGatewayProxyResponse{StatusCode: 500}, nil
+ }
+
+ // Checking type
+ if len(result.Item) == 0 {
+ return events.APIGatewayProxyResponse{StatusCode: 404}, nil
+ }
+
+ // Created item of type Item
+ item := Item{}
+
+ // result is of type *dynamodb.GetItemOutput
+ // result.Item is of type map[string]*dynamodb.AttributeValue
+ // UnmarshallMap result.item into item
+ err = dynamodbattribute.UnmarshalMap(result.Item, &item)
+
+ if err != nil {
+ panic(fmt.Sprintf("Failed to UnmarshalMap result.Item: ", err))
+ }
+
+ // Marshal to type []uint8
+ marshalledItem, err := json.Marshal(item)
+
+ // Return marshalled item
+ return events.APIGatewayProxyResponse{Body: string(marshalledItem), StatusCode: 200}, nil
+}
+
+func main() {
+ lambda.Start(Handler)
+}
diff --git a/aws-golang-rest-api-with-dynamodb/todos/list.go b/aws-golang-rest-api-with-dynamodb/todos/list.go
new file mode 100644
index 000000000..a3d41a885
--- /dev/null
+++ b/aws-golang-rest-api-with-dynamodb/todos/list.go
@@ -0,0 +1,77 @@
+package main
+
+import (
+ "github.com/aws/aws-lambda-go/events"
+ "github.com/aws/aws-lambda-go/lambda"
+ "github.com/aws/aws-sdk-go/aws"
+ "github.com/aws/aws-sdk-go/aws/session"
+ "github.com/aws/aws-sdk-go/service/dynamodb"
+ "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
+
+ "encoding/json"
+ "fmt"
+ "os"
+)
+
+type Item struct {
+ Id string `json:"id,omitempty"`
+ Title string `json:"title"`
+ Details string `json:"details"`
+}
+
+func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
+
+ // Creating session for client
+ sess := session.Must(session.NewSessionWithOptions(session.Options{
+ SharedConfigState: session.SharedConfigEnable,
+ }))
+
+ // Create DynamoDB client
+ svc := dynamodb.New(sess)
+
+ // Build the query input parameters
+ params := &dynamodb.ScanInput{
+ TableName: aws.String(os.Getenv("DYNAMODB_TABLE")),
+ }
+
+ // Scan table
+ result, err := svc.Scan(params)
+
+ // Checking for errors, return error
+ if err != nil {
+ fmt.Println("Query API call failed: ", err.Error())
+ return events.APIGatewayProxyResponse{StatusCode: 500}, nil
+ }
+
+ var itemArray []Item
+
+ for _, i := range result.Items {
+ item := Item{}
+
+ // result is of type *dynamodb.GetItemOutput
+ // result.Item is of type map[string]*dynamodb.AttributeValue
+ // UnmarshallMap result.item to item
+ err = dynamodbattribute.UnmarshalMap(i, &item)
+
+ if err != nil {
+ fmt.Println("Got error unmarshalling: ", err.Error())
+ return events.APIGatewayProxyResponse{StatusCode: 500}, nil
+ }
+
+ itemArray = append(itemArray, item)
+ }
+
+ fmt.Println("itemArray: ", itemArray)
+
+ itemArrayString, err := json.Marshal(itemArray)
+ if err != nil {
+ fmt.Println("Got error marshalling result: ", err.Error())
+ return events.APIGatewayProxyResponse{StatusCode: 500}, nil
+ }
+
+ return events.APIGatewayProxyResponse{Body: string(itemArrayString), StatusCode: 200}, nil
+}
+
+func main() {
+ lambda.Start(Handler)
+}
diff --git a/aws-golang-rest-api-with-dynamodb/todos/update.go b/aws-golang-rest-api-with-dynamodb/todos/update.go
new file mode 100644
index 000000000..7029aa37e
--- /dev/null
+++ b/aws-golang-rest-api-with-dynamodb/todos/update.go
@@ -0,0 +1,79 @@
+package main
+
+import (
+ "github.com/aws/aws-lambda-go/events"
+ "github.com/aws/aws-lambda-go/lambda"
+ "github.com/aws/aws-sdk-go/aws"
+ "github.com/aws/aws-sdk-go/aws/session"
+ "github.com/aws/aws-sdk-go/service/dynamodb"
+
+ "encoding/json"
+ "fmt"
+ "os"
+)
+
+type Item struct {
+ Id string `json:"id,omitempty"`
+ Title string `json:"title"`
+ Details string `json:"details"`
+}
+
+func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
+
+ // Creating session for client
+ sess := session.Must(session.NewSessionWithOptions(session.Options{
+ SharedConfigState: session.SharedConfigEnable,
+ }))
+
+ // Create DynamoDB client
+ svc := dynamodb.New(sess)
+
+ pathParamId := request.PathParameters["id"]
+
+ itemString := request.Body
+ itemStruct := Item{}
+ json.Unmarshal([]byte(itemString), &itemStruct)
+
+ info := Item{
+ Title: itemStruct.Title,
+ Details: itemStruct.Details,
+ }
+
+ fmt.Println("Updating title to: ", info.Title)
+ fmt.Println("Updating details to: ", info.Details)
+
+ // Prepare input for Update Item
+ input := &dynamodb.UpdateItemInput{
+ ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
+ ":t": {
+ S: aws.String(info.Title),
+ },
+ ":d": {
+ S: aws.String(info.Details),
+ },
+ },
+ TableName: aws.String(os.Getenv("DYNAMODB_TABLE")),
+ Key: map[string]*dynamodb.AttributeValue{
+ "id": {
+ S: aws.String(pathParamId),
+ },
+ },
+ ReturnValues: aws.String("UPDATED_NEW"),
+ UpdateExpression: aws.String("set title = :t, details = :d"),
+ }
+
+ // UpdateItem request
+ _, err := svc.UpdateItem(input)
+
+ // Checking for errors, return error
+ if err != nil {
+ fmt.Println(err.Error())
+ return events.APIGatewayProxyResponse{StatusCode: 500}, nil
+ }
+
+ return events.APIGatewayProxyResponse{StatusCode: 204}, nil
+}
+
+func main() {
+ lambda.Start(Handler)
+}
diff --git a/aws-golang-s3-file-replicator/Makefile b/aws-golang-s3-file-replicator/Makefile
index 2e7e27454..d47bd3465 100644
--- a/aws-golang-s3-file-replicator/Makefile
+++ b/aws-golang-s3-file-replicator/Makefile
@@ -2,7 +2,7 @@
build: gomodgen
export GO111MODULE=on
- env GOOS=linux go build -ldflags="-s -w" -o bin/replicator src/main.go
+ env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o bin/replicator src/main.go
clean:
rm -rf ./bin ./vendor Gopkg.lock
diff --git a/aws-golang-s3-file-replicator/README.md b/aws-golang-s3-file-replicator/README.md
index 3692d1eee..7c790a295 100644
--- a/aws-golang-s3-file-replicator/README.md
+++ b/aws-golang-s3-file-replicator/README.md
@@ -4,6 +4,7 @@ description: 'Boilerplate code for Golang with S3 object create event and replic
framework: v1
platform: AWS
language: Go
+priority: 10
authorLink: 'https://github.com/p0n2'
authorName: 'p0n2'
authorAvatar: 'https://avatars3.githubusercontent.com/u/59630164'
diff --git a/aws-golang-s3-file-replicator/serverless.yml b/aws-golang-s3-file-replicator/serverless.yml
index 614122479..32705772b 100644
--- a/aws-golang-s3-file-replicator/serverless.yml
+++ b/aws-golang-s3-file-replicator/serverless.yml
@@ -1,5 +1,5 @@
service: aws-golang-s3-file-replicator
-frameworkVersion: ">=1.28.0 <2.0.0"
+frameworkVersion: ">=2.24.0"
custom:
inputBucket: replicator-input-101
@@ -12,15 +12,17 @@ provider:
region: ap-northeast-1
memorySize: 128
timeout: 30
- iamRoleStatements:
- - Effect: Allow
- Action:
- - s3:*
- Resource: "arn:aws:s3:::${self:custom.outputBucket}/*"
- - Effect: Allow
- Action:
- - s3:*
- Resource: "arn:aws:s3:::${self:custom.inputBucket}/*"
+ iam:
+ role:
+ statements:
+ - Effect: Allow
+ Action:
+ - s3:*
+ Resource: "arn:aws:s3:::${self:custom.outputBucket}/*"
+ - Effect: Allow
+ Action:
+ - s3:*
+ Resource: "arn:aws:s3:::${self:custom.inputBucket}/*"
package:
exclude:
diff --git a/aws-golang-simple-http-endpoint/Makefile b/aws-golang-simple-http-endpoint/Makefile
index 4e281fb7d..0b06197a7 100644
--- a/aws-golang-simple-http-endpoint/Makefile
+++ b/aws-golang-simple-http-endpoint/Makefile
@@ -1,7 +1,7 @@
build:
dep ensure -v
- env GOOS=linux go build -ldflags="-s -w" -o bin/hello hello/main.go
- env GOOS=linux go build -ldflags="-s -w" -o bin/world world/main.go
+ env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o bin/hello hello/main.go
+ env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o bin/world world/main.go
.PHONY: clean
clean:
diff --git a/aws-golang-simple-http-endpoint/README.md b/aws-golang-simple-http-endpoint/README.md
index 9a63b3612..40deff90d 100644
--- a/aws-golang-simple-http-endpoint/README.md
+++ b/aws-golang-simple-http-endpoint/README.md
@@ -5,7 +5,8 @@ layout: Doc
framework: v1
platform: AWS
language: Go
+priority: 10
authorLink: 'https://github.com/sebito91'
authorName: 'Sebastian Borza'
authorAvatar: 'https://avatars0.githubusercontent.com/u/3159454?v=4&s=140'
--->
\ No newline at end of file
+-->
diff --git a/aws-golang-simple-http-endpoint/serverless.yml b/aws-golang-simple-http-endpoint/serverless.yml
index 4afac44b1..2585a31e1 100644
--- a/aws-golang-simple-http-endpoint/serverless.yml
+++ b/aws-golang-simple-http-endpoint/serverless.yml
@@ -1,6 +1,5 @@
service: aws-golang-simple-http-endpoint
-
-frameworkVersion: ">=1.28.0 <2.0.0"
+frameworkVersion: '2'
provider:
name: aws
@@ -10,14 +9,14 @@ functions:
hello:
handler: bin/hello
events:
- - http:
- path: hello
+ - httpApi:
+ path: /hello
method: get
world:
handler: bin/world
events:
- - http:
- path: world
+ - httpApi:
+ path: /world
method: get
package:
diff --git a/aws-golang-stream-kinesis-to-elasticsearch/Makefile b/aws-golang-stream-kinesis-to-elasticsearch/Makefile
index b07001f9e..9e54a09f5 100644
--- a/aws-golang-stream-kinesis-to-elasticsearch/Makefile
+++ b/aws-golang-stream-kinesis-to-elasticsearch/Makefile
@@ -1,6 +1,6 @@
build:
dep ensure -v
- env GOOS=linux go build -ldflags="-s -w" -o bin/stream main.go
+ env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o bin/stream main.go
.PHONY: clean
clean:
diff --git a/aws-golang-stream-kinesis-to-elasticsearch/README.md b/aws-golang-stream-kinesis-to-elasticsearch/README.md
index a4ccd7b34..08a9d083b 100644
--- a/aws-golang-stream-kinesis-to-elasticsearch/README.md
+++ b/aws-golang-stream-kinesis-to-elasticsearch/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: Go
+priority: 10
authorLink: 'https://github.com/sebito91'
authorName: 'Sebastian Borza'
authorAvatar: 'https://avatars0.githubusercontent.com/u/3159454?v=4&s=140'
diff --git a/aws-java-simple-http-endpoint/README.md b/aws-java-simple-http-endpoint/README.md
index ddfafa6be..3ea9670a5 100644
--- a/aws-java-simple-http-endpoint/README.md
+++ b/aws-java-simple-http-endpoint/README.md
@@ -1,17 +1,18 @@
# Simple HTTP Endpoint Example
-This example demonstrates how to setup a simple HTTP GET endpoint using Java. Once you ping it, it will reply with the current time.
+This example demonstrates how to setup a simple HTTP GET endpoint using Java. Once you fetch it, it will reply with the current time.
[Jackson](https://github.com/FasterXML/jackson) is used to serialize objects to JSON.
@@ -109,7 +110,7 @@ region: us-east-1
api keys:
None
endpoints:
- GET - https://XXXXXXX.execute-api.us-east-1.amazonaws.com/dev/ping
+ GET - https://XXXXXXX.execute-api.us-east-1.amazonaws.com/time
functions:
aws-java-simple-http-endpoint-dev-currentTime: arn:aws:lambda:us-east-1:XXXXXXX:function:aws-java-simple-http-endpoint-dev-currentTime
@@ -145,7 +146,7 @@ REPORT RequestId: XXXXXXX Duration: 0.51 ms Billed Duration: 100 ms Memory Size
Finally you can send an HTTP request directly to the endpoint using a tool like curl
```bash
-curl https://XXXXXXX.execute-api.us-east-1.amazonaws.com/dev/ping
+curl https://XXXXXXX.execute-api.us-east-1.amazonaws.com/time
```
The expected result should be similar to:
@@ -156,4 +157,4 @@ The expected result should be similar to:
## Scaling
-By default, AWS Lambda limits the total concurrent executions across all functions within a given region to 100. The default limit is a safety limit that protects you from costs due to potential runaway or recursive functions during initial development and testing. To increase this limit above the default, follow the steps in [To request a limit increase for concurrent executions](http://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html#increase-concurrent-executions-limit).
+By default, AWS Lambda limits the total concurrent executions across all functions within a given region to 1000. The default limit is a safety limit that protects you from costs due to potential runaway or recursive functions during initial development and testing. To increase this limit above the default, follow the steps in [To request a limit increase for concurrent executions](http://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html#increase-concurrent-executions-limit).
diff --git a/aws-java-simple-http-endpoint/pom.xml b/aws-java-simple-http-endpoint/pom.xml
index 8f7c4a086..fcf8f08ed 100644
--- a/aws-java-simple-http-endpoint/pom.xml
+++ b/aws-java-simple-http-endpoint/pom.xml
@@ -32,7 +32,7 @@
com.fasterxml.jackson.core
jackson-databind
- 2.9.10.4
+ 2.10.0.pr1
com.fasterxml.jackson.core
diff --git a/aws-java-simple-http-endpoint/serverless.yml b/aws-java-simple-http-endpoint/serverless.yml
index d271c7d01..f783b718c 100644
--- a/aws-java-simple-http-endpoint/serverless.yml
+++ b/aws-java-simple-http-endpoint/serverless.yml
@@ -1,11 +1,10 @@
service: aws-java-simple-http-endpoint
-
-frameworkVersion: ">=1.2.0 <2.0.0"
+frameworkVersion: '2'
provider:
name: aws
runtime: java8
-
+
package:
artifact: build/distributions/aws-java-simple-http-endpoint.zip
@@ -13,6 +12,6 @@ functions:
currentTime:
handler: com.serverless.Handler
events:
- - http:
- path: ping
+ - httpApi:
+ path: /time
method: get
diff --git a/aws-multiple-runtime/README.md b/aws-multiple-runtime/README.md
index 23d23630f..c6f7513d2 100644
--- a/aws-multiple-runtime/README.md
+++ b/aws-multiple-runtime/README.md
@@ -5,7 +5,8 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/christophgysin'
authorName: 'Christoph Gysin'
authorAvatar: 'https://avatars0.githubusercontent.com/u/527924?v=4&s=140'
--->
\ No newline at end of file
+-->
diff --git a/aws-multiple-runtime/serverless.yml b/aws-multiple-runtime/serverless.yml
index 88c1fe949..4c5abf22e 100644
--- a/aws-multiple-runtime/serverless.yml
+++ b/aws-multiple-runtime/serverless.yml
@@ -6,14 +6,14 @@ functions:
hello:
runtime: python3.6
events:
- - http:
+ - httpApi:
method: get
- path: greet
+ path: /greet
handler: web/handler.hello
time:
runtime: nodejs12.x
events:
- - http:
+ - httpApi:
method: get
- path: time
+ path: /time
handler: api/handler.timestamp
diff --git a/aws-node-alexa-skill/README.md b/aws-node-alexa-skill/README.md
index cceabbb66..99e64bf11 100644
--- a/aws-node-alexa-skill/README.md
+++ b/aws-node-alexa-skill/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/rupakg'
authorName: 'Rupak Ganguly'
authorAvatar: 'https://avatars0.githubusercontent.com/u/8188?v=4&s=140'
diff --git a/aws-node-auth0-cognito-custom-authorizers-api/README.md b/aws-node-auth0-cognito-custom-authorizers-api/README.md
index 18c3b5ffb..faeb667d3 100644
--- a/aws-node-auth0-cognito-custom-authorizers-api/README.md
+++ b/aws-node-auth0-cognito-custom-authorizers-api/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/shahzeb1'
authorName: 'Shahzeb K.'
authorAvatar: 'https://avatars2.githubusercontent.com/u/1383831?v=4&s=140'
diff --git a/aws-node-auth0-custom-authorizers-api/README.md b/aws-node-auth0-custom-authorizers-api/README.md
index 758d7d7d4..64b8af4af 100644
--- a/aws-node-auth0-custom-authorizers-api/README.md
+++ b/aws-node-auth0-custom-authorizers-api/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/erezrokah'
authorName: 'Erez Rokah'
authorAvatar: 'https://avatars0.githubusercontent.com/u/26760571?v=4&s=140'
diff --git a/aws-node-auth0-custom-authorizers-api/yarn.lock b/aws-node-auth0-custom-authorizers-api/yarn.lock
index 5df957e3e..91b4ded33 100644
--- a/aws-node-auth0-custom-authorizers-api/yarn.lock
+++ b/aws-node-auth0-custom-authorizers-api/yarn.lock
@@ -488,8 +488,8 @@ lodash.once@^4.0.0:
resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac"
lodash@^4.17.4:
- version "4.17.15"
- resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
+ version "4.17.20"
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
loose-envify@^1.0.0:
version "1.3.1"
diff --git a/aws-node-dynamic-image-resizer/README.md b/aws-node-dynamic-image-resizer/README.md
index 74963e316..81d8d1e5c 100755
--- a/aws-node-dynamic-image-resizer/README.md
+++ b/aws-node-dynamic-image-resizer/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/sebito91'
authorName: 'Sebastian Borza'
authorAvatar: 'https://avatars0.githubusercontent.com/u/3159454?v=4&s=140'
diff --git a/aws-node-dynamic-image-resizer/package.json b/aws-node-dynamic-image-resizer/package.json
index 854ba4463..960fad73b 100644
--- a/aws-node-dynamic-image-resizer/package.json
+++ b/aws-node-dynamic-image-resizer/package.json
@@ -14,7 +14,7 @@
"dependencies": {
"@babel/runtime": "^7.3.1",
"babel-runtime": "^7.0.0-beta.3",
- "lodash": "^4.17.13",
+ "lodash": "^4.17.19",
"serverless-offline": "^4.7.0",
"serverless-webpack": "^5.2.0",
"sharp": "^0.21.3",
diff --git a/aws-node-dynamic-image-resizer/yarn.lock b/aws-node-dynamic-image-resizer/yarn.lock
index 2b991c124..1d0207c4a 100644
--- a/aws-node-dynamic-image-resizer/yarn.lock
+++ b/aws-node-dynamic-image-resizer/yarn.lock
@@ -1802,9 +1802,9 @@ bluebird@^3.5.0, bluebird@^3.5.1, bluebird@^3.5.3:
integrity sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==
bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0:
- version "4.11.8"
- resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f"
- integrity sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==
+ version "4.11.9"
+ resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828"
+ integrity sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==
boom@5.x.x:
version "5.2.0"
@@ -2830,9 +2830,9 @@ electron-to-chromium@^1.3.113, electron-to-chromium@^1.3.47:
integrity sha512-De+lPAxEcpxvqPTyZAXELNpRZXABRxf+uL/rSykstQhzj/B0l1150G/ExIIxKc16lI89Hgz81J0BHAcbTqK49g==
elliptic@^6.0.0:
- version "6.4.1"
- resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.4.1.tgz#c2d0b7776911b86722c632c3c06c60f2f819939a"
- integrity sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==
+ version "6.5.3"
+ resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.3.tgz#cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6"
+ integrity sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==
dependencies:
bn.js "^4.4.0"
brorand "^1.0.1"
@@ -3857,16 +3857,21 @@ inflight@^1.0.4:
once "^1.3.0"
wrappy "1"
-inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.1, inherits@~2.0.3:
- version "2.0.3"
- resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
- integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=
+inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.1, inherits@~2.0.3:
+ version "2.0.4"
+ resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
+ integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
inherits@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1"
integrity sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=
+inherits@2.0.3:
+ version "2.0.3"
+ resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
+ integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=
+
ini@^1.3.4, ini@~1.3.0:
version "1.3.5"
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927"
@@ -5104,10 +5109,10 @@ lodash.uniq@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
-lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.8.0:
- version "4.17.13"
- resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.13.tgz#0bdc3a6adc873d2f4e0c4bac285df91b64fc7b93"
- integrity sha512-vm3/XWXfWtRua0FkUyEHBZy8kCPjErNBT9fJx8Zvs+U6zjqPbTUOpkaoum3O5uiA8sm+yNMHXfYkTUHFoMxFNA==
+lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.8.0:
+ version "4.17.19"
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
+ integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
loose-envify@^1.0.0:
version "1.4.0"
diff --git a/aws-node-dynamodb-backup/README.md b/aws-node-dynamodb-backup/README.md
index 4cf98d409..2fc36828b 100644
--- a/aws-node-dynamodb-backup/README.md
+++ b/aws-node-dynamodb-backup/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/kaihendry'
authorName: 'Kai Hendry'
authorAvatar: 'https://avatars3.githubusercontent.com/u/765871?v=4&s=140'
diff --git a/aws-node-dynamodb-backup/serverless.yml b/aws-node-dynamodb-backup/serverless.yml
index db56f3a6b..22e8120d1 100644
--- a/aws-node-dynamodb-backup/serverless.yml
+++ b/aws-node-dynamodb-backup/serverless.yml
@@ -9,18 +9,20 @@ provider:
name: aws
runtime: nodejs12.x
stage: staging
- iamRoleStatements:
- - Effect: Allow
- Action:
- - s3:PutObject
- Resource: "arn:aws:s3:::${self:custom.bucket}/${self:custom.prefix}/${self:custom.dynamoDBTableName}/*"
- - Effect: Allow
- Action:
- - "dynamodb:GetRecords"
- - "dynamodb:GetShardIterator"
- - "dynamodb:DescribeStream"
- - "dynamodb:ListStreams"
- Resource: "arn:aws:dynamodb:ap-southeast-1:*:table/${self:custom.dynamoDBTableName}/stream/*"
+ iam:
+ role:
+ statements:
+ - Effect: Allow
+ Action:
+ - s3:PutObject
+ Resource: "arn:aws:s3:::${self:custom.bucket}/${self:custom.prefix}/${self:custom.dynamoDBTableName}/*"
+ - Effect: Allow
+ Action:
+ - "dynamodb:GetRecords"
+ - "dynamodb:GetShardIterator"
+ - "dynamodb:DescribeStream"
+ - "dynamodb:ListStreams"
+ Resource: "arn:aws:dynamodb:ap-southeast-1:*:table/${self:custom.dynamoDBTableName}/stream/*"
functions:
backup:
diff --git a/aws-node-env-variables-encrypted-in-a-file/README.md b/aws-node-env-variables-encrypted-in-a-file/README.md
index 7c1afb270..9b39b2b76 100644
--- a/aws-node-env-variables-encrypted-in-a-file/README.md
+++ b/aws-node-env-variables-encrypted-in-a-file/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/rupakg'
authorName: 'Rupak Ganguly'
authorAvatar: 'https://avatars0.githubusercontent.com/u/8188?v=4&s=140'
diff --git a/aws-node-env-variables/README.md b/aws-node-env-variables/README.md
index e2ffa0c59..a04cdae13 100644
--- a/aws-node-env-variables/README.md
+++ b/aws-node-env-variables/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/rupakg'
authorName: 'Rupak Ganguly'
authorAvatar: 'https://avatars0.githubusercontent.com/u/8188?v=4&s=140'
diff --git a/aws-node-express-api/.gitignore b/aws-node-express-api/.gitignore
new file mode 100644
index 000000000..2c4448065
--- /dev/null
+++ b/aws-node-express-api/.gitignore
@@ -0,0 +1,2 @@
+node_modules
+.serverless
diff --git a/aws-node-express-api/README.md b/aws-node-express-api/README.md
new file mode 100644
index 000000000..fea525540
--- /dev/null
+++ b/aws-node-express-api/README.md
@@ -0,0 +1,127 @@
+
+
+# Serverless Framework Node Express API on AWS
+
+This template demonstrates how to develop and deploy a simple Node Express API service running on AWS Lambda using the traditional Serverless Framework.
+
+## Anatomy of the template
+
+This template configures a single function, `api`, which is responsible for handling all incoming requests thanks to the `httpApi` event. To learn more about `httpApi` event configuration options, please refer to [httpApi event docs](https://www.serverless.com/framework/docs/providers/aws/events/http-api/). As the event is configured in a way to accept all incoming requests, `express` framework is responsible for routing and handling requests internally. Implementation takes advantage of `serverless-http` package, which allows you to wrap existing `express` applications. To learn more about `serverless-http`, please refer to corresponding [GitHub repository](https://github.com/dougmoscrop/serverless-http).
+
+## Usage
+
+### Deployment
+
+Install dependencies with:
+
+```
+npm install
+```
+
+and then deploy with:
+
+```
+serverless deploy
+```
+
+After running deploy, you should see output similar to:
+
+```bash
+Serverless: Packaging service...
+Serverless: Excluding development dependencies...
+Serverless: Creating Stack...
+Serverless: Checking Stack create progress...
+........
+Serverless: Stack create finished...
+Serverless: Uploading CloudFormation file to S3...
+Serverless: Uploading artifacts...
+Serverless: Uploading service aws-node-express-api.zip file to S3 (711.23 KB)...
+Serverless: Validating template...
+Serverless: Updating Stack...
+Serverless: Checking Stack update progress...
+.................................
+Serverless: Stack update finished...
+Service Information
+service: aws-node-express-api
+stage: dev
+region: us-east-1
+stack: aws-node-express-api-dev
+resources: 12
+api keys:
+ None
+endpoints:
+ ANY - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/
+functions:
+ api: aws-node-express-api-dev-api
+layers:
+ None
+```
+
+_Note_: In current form, after deployment, your API is public and can be invoked by anyone. For production deployments, you might want to configure an authorizer. For details on how to do that, refer to [`httpApi` event docs](https://www.serverless.com/framework/docs/providers/aws/events/http-api/).
+
+### Invocation
+
+After successful deployment, you can call the created application via HTTP:
+
+```bash
+curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/
+```
+
+Which should result in the following response:
+
+```
+{"message":"Hello from root!"}
+```
+
+Calling the `/hello` path with:
+
+```bash
+curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/hello
+```
+
+Should result in the following response:
+
+```bash
+{"message":"Hello from path!"}
+```
+
+If you try to invoke a path or method that does not have a configured handler, e.g. with:
+
+```bash
+curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/nonexistent
+```
+
+You should receive the following response:
+
+```bash
+{"error":"Not Found"}
+```
+
+### Local development
+
+It is also possible to emulate API Gateway and Lambda locally by using `serverless-offline` plugin. In order to do that, execute the following command:
+
+```bash
+serverless plugin install -n serverless-offline
+```
+
+It will add the `serverless-offline` plugin to `devDependencies` in `package.json` file as well as will add it to `plugins` in `serverless.yml`.
+
+After installation, you can start local emulation with:
+
+```
+serverless offline
+```
+
+To learn more about the capabilities of `serverless-offline`, please refer to its [GitHub repository](https://github.com/dherault/serverless-offline).
diff --git a/aws-node-express-api/handler.js b/aws-node-express-api/handler.js
new file mode 100644
index 000000000..73a78fada
--- /dev/null
+++ b/aws-node-express-api/handler.js
@@ -0,0 +1,23 @@
+const serverless = require("serverless-http");
+const express = require("express");
+const app = express();
+
+app.get("/", (req, res, next) => {
+ return res.status(200).json({
+ message: "Hello from root!",
+ });
+});
+
+app.get("/hello", (req, res, next) => {
+ return res.status(200).json({
+ message: "Hello from path!",
+ });
+});
+
+app.use((req, res, next) => {
+ return res.status(404).json({
+ error: "Not Found",
+ });
+});
+
+module.exports.handler = serverless(app);
diff --git a/aws-node-express-api/package.json b/aws-node-express-api/package.json
new file mode 100644
index 000000000..b16219146
--- /dev/null
+++ b/aws-node-express-api/package.json
@@ -0,0 +1,9 @@
+{
+ "name": "aws-node-express-api",
+ "version": "1.0.0",
+ "description": "",
+ "dependencies": {
+ "express": "^4.17.1",
+ "serverless-http": "^2.7.0"
+ }
+}
diff --git a/aws-node-express-api/serverless.template.yml b/aws-node-express-api/serverless.template.yml
new file mode 100644
index 000000000..f29ef7f8e
--- /dev/null
+++ b/aws-node-express-api/serverless.template.yml
@@ -0,0 +1,6 @@
+name: aws-node-express-api
+org: serverlessinc
+description: Deploys a Node Express API service with Serverless Framework
+keywords: aws, serverless, faas, lambda, node, express
+repo: https://github.com/serverless/examples/aws-node-express-api
+license: MIT
diff --git a/aws-node-express-api/serverless.yml b/aws-node-express-api/serverless.yml
new file mode 100644
index 000000000..8a1fff8cd
--- /dev/null
+++ b/aws-node-express-api/serverless.yml
@@ -0,0 +1,13 @@
+service: aws-node-express-api
+frameworkVersion: '2 || 3'
+
+provider:
+ name: aws
+ runtime: nodejs12.x
+ lambdaHashingVersion: '20201221'
+
+functions:
+ api:
+ handler: handler.handler
+ events:
+ - httpApi: '*'
diff --git a/aws-node-express-dynamodb-api/.gitignore b/aws-node-express-dynamodb-api/.gitignore
new file mode 100644
index 000000000..2c4448065
--- /dev/null
+++ b/aws-node-express-dynamodb-api/.gitignore
@@ -0,0 +1,2 @@
+node_modules
+.serverless
diff --git a/aws-node-express-dynamodb-api/README.md b/aws-node-express-dynamodb-api/README.md
new file mode 100644
index 000000000..d3fdf78bc
--- /dev/null
+++ b/aws-node-express-dynamodb-api/README.md
@@ -0,0 +1,160 @@
+
+
+# Serverless Framework Node Express API on AWS
+
+This template demonstrates how to develop and deploy a simple Node Express API service, backed by DynamoDB database, running on AWS Lambda using the traditional Serverless Framework.
+
+
+## Anatomy of the template
+
+This template configures a single function, `api`, which is responsible for handling all incoming requests thanks to the `httpApi` event. To learn more about `httpApi` event configuration options, please refer to [httpApi event docs](https://www.serverless.com/framework/docs/providers/aws/events/http-api/). As the event is configured in a way to accept all incoming requests, `express` framework is responsible for routing and handling requests internally. Implementation takes advantage of `serverless-http` package, which allows you to wrap existing `express` applications. To learn more about `serverless-http`, please refer to corresponding [GitHub repository](https://github.com/dougmoscrop/serverless-http). Additionally, it also handles provisioning of a DynamoDB database that is used for storing data about users. The `express` application exposes two endpoints, `POST /users` and `GET /user/{userId}`, which allow to create and retrieve users.
+
+## Usage
+
+### Deployment
+
+Install dependencies with:
+
+```
+npm install
+```
+
+and then deploy with:
+
+```
+serverless deploy
+```
+
+After running deploy, you should see output similar to:
+
+```bash
+Serverless: Packaging service...
+Serverless: Excluding development dependencies...
+Serverless: Creating Stack...
+Serverless: Checking Stack create progress...
+........
+Serverless: Stack create finished...
+Serverless: Uploading CloudFormation file to S3...
+Serverless: Uploading artifacts...
+Serverless: Uploading service aws-node-express-dynamodb-api.zip file to S3 (718.53 KB)...
+Serverless: Validating template...
+Serverless: Updating Stack...
+Serverless: Checking Stack update progress...
+....................................
+Serverless: Stack update finished...
+Service Information
+service: aws-node-express-dynamodb-api
+stage: dev
+region: us-east-1
+stack: aws-node-express-dynamodb-api-dev
+resources: 13
+api keys:
+ None
+endpoints:
+ ANY - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/
+functions:
+ api: aws-node-express-dynamodb-api-dev-api
+layers:
+ None
+```
+
+_Note_: In current form, after deployment, your API is public and can be invoked by anyone. For production deployments, you might want to configure an authorizer. For details on how to do that, refer to [`httpApi` event docs](https://www.serverless.com/framework/docs/providers/aws/events/http-api/). Additionally, in current configuration, the DynamoDB table will be removed when running `serverless remove`. To retain the DynamoDB table even after removal of the stack, add `DeletionPolicy: Retain` to its resource definition.
+
+### Invocation
+
+After successful deployment, you can create a new user by calling the corresponding endpoint:
+
+```bash
+curl --request POST 'https://xxxxxx.execute-api.us-east-1.amazonaws.com/users' --header 'Content-Type: application/json' --data-raw '{"name": "John", "userId": "someUserId"}'
+```
+
+Which should result in the following response:
+
+```bash
+{"userId":"someUserId","name":"John"}
+```
+
+You can later retrieve the user by `userId` by calling the following endpoint:
+
+```bash
+curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/users/someUserId
+```
+
+Which should result in the following response:
+
+```bash
+{"userId":"someUserId","name":"John"}
+```
+
+If you try to retrieve user that does not exist, you should receive the following response:
+
+```bash
+{"error":"Could not find user with provided \"userId\""}
+```
+
+### Local development
+
+It is also possible to emulate DynamoDB, API Gateway and Lambda locally using the `serverless-dynamodb-local` and `serverless-offline` plugins. In order to do that, run:
+
+```bash
+serverless plugin install -n serverless-dynamodb-local
+serverless plugin install -n serverless-offline
+```
+
+It will add both plugins to `devDependencies` in `package.json` file as well as will add it to `plugins` in `serverless.yml`. Make sure that `serverless-offline` is listed as last plugin in `plugins` section:
+
+```
+plugins:
+ - serverless-dynamodb-local
+ - serverless-offline
+```
+
+You should also add the following config to `custom` section in `serverless.yml`:
+
+```
+custom:
+ (...)
+ dynamodb:
+ start:
+ migrate: true
+ stages:
+ - dev
+```
+
+Additionally, we need to reconfigure `AWS.DynamoDB.DocumentClient` to connect to our local instance of DynamoDB. We can take advantage of `IS_OFFLINE` environment variable set by `serverless-offline` plugin and replace:
+
+```javascript
+const dynamoDbClient = new AWS.DynamoDB.DocumentClient();
+```
+
+with the following:
+
+```javascript
+const dynamoDbClientParams = {};
+if (process.env.IS_OFFLINE) {
+ dynamoDbClientParams.region = 'localhost'
+ dynamoDbClientParams.endpoint = 'http://localhost:8000'
+}
+const dynamoDbClient = new AWS.DynamoDB.DocumentClient(dynamoDbClientParams);
+```
+
+After that, running the following command with start both local API Gateway emulator as well as local instance of emulated DynamoDB:
+
+```bash
+serverless offline start
+```
+
+To learn more about the capabilities of `serverless-offline` and `serverless-dynamodb-local`, please refer to their corresponding GitHub repositories:
+- https://github.com/dherault/serverless-offline
+- https://github.com/99x/serverless-dynamodb-local
diff --git a/aws-node-express-dynamodb-api/handler.js b/aws-node-express-dynamodb-api/handler.js
new file mode 100644
index 000000000..8bc34d33e
--- /dev/null
+++ b/aws-node-express-dynamodb-api/handler.js
@@ -0,0 +1,68 @@
+const AWS = require("aws-sdk");
+const express = require("express");
+const serverless = require("serverless-http");
+
+const app = express();
+
+const USERS_TABLE = process.env.USERS_TABLE;
+const dynamoDbClient = new AWS.DynamoDB.DocumentClient();
+
+app.use(express.json());
+
+app.get("/users/:userId", async function (req, res) {
+ const params = {
+ TableName: USERS_TABLE,
+ Key: {
+ userId: req.params.userId,
+ },
+ };
+
+ try {
+ const { Item } = await dynamoDbClient.get(params).promise();
+ if (Item) {
+ const { userId, name } = Item;
+ res.json({ userId, name });
+ } else {
+ res
+ .status(404)
+ .json({ error: 'Could not find user with provided "userId"' });
+ }
+ } catch (error) {
+ console.log(error);
+ res.status(500).json({ error: "Could not retreive user" });
+ }
+});
+
+app.post("/users", async function (req, res) {
+ const { userId, name } = req.body;
+ if (typeof userId !== "string") {
+ res.status(400).json({ error: '"userId" must be a string' });
+ } else if (typeof name !== "string") {
+ res.status(400).json({ error: '"name" must be a string' });
+ }
+
+ const params = {
+ TableName: USERS_TABLE,
+ Item: {
+ userId: userId,
+ name: name,
+ },
+ };
+
+ try {
+ await dynamoDbClient.put(params).promise();
+ res.json({ userId, name });
+ } catch (error) {
+ console.log(error);
+ res.status(500).json({ error: "Could not create user" });
+ }
+});
+
+app.use((req, res, next) => {
+ return res.status(404).json({
+ error: "Not Found",
+ });
+});
+
+
+module.exports.handler = serverless(app);
diff --git a/aws-node-express-dynamodb-api/package.json b/aws-node-express-dynamodb-api/package.json
new file mode 100644
index 000000000..2e1c7cd4f
--- /dev/null
+++ b/aws-node-express-dynamodb-api/package.json
@@ -0,0 +1,9 @@
+{
+ "name": "aws-node-express-dynamodb-api",
+ "version": "1.0.0",
+ "description": "",
+ "dependencies": {
+ "express": "^4.17.1",
+ "serverless-http": "^2.7.0"
+ }
+}
diff --git a/aws-node-express-dynamodb-api/serverless.template.yml b/aws-node-express-dynamodb-api/serverless.template.yml
new file mode 100644
index 000000000..520752083
--- /dev/null
+++ b/aws-node-express-dynamodb-api/serverless.template.yml
@@ -0,0 +1,6 @@
+name: aws-node-express-dynamodb-api
+org: serverlessinc
+description: Deploys a Node Express API service backed by DynamoDB with Serverless Framework
+keywords: aws, serverless, faas, lambda, node, express, dynamodb
+repo: https://github.com/serverless/examples/aws-node-express-dynamodb-api
+license: MIT
diff --git a/aws-node-express-dynamodb-api/serverless.yml b/aws-node-express-dynamodb-api/serverless.yml
new file mode 100644
index 000000000..ac64d2e65
--- /dev/null
+++ b/aws-node-express-dynamodb-api/serverless.yml
@@ -0,0 +1,45 @@
+service: aws-node-express-dynamodb-api
+frameworkVersion: '2 || 3'
+
+custom:
+ tableName: 'users-table-${sls:stage}'
+
+provider:
+ name: aws
+ runtime: nodejs12.x
+ lambdaHashingVersion: '20201221'
+ iam:
+ role:
+ statements:
+ - Effect: Allow
+ Action:
+ - dynamodb:Query
+ - dynamodb:Scan
+ - dynamodb:GetItem
+ - dynamodb:PutItem
+ - dynamodb:UpdateItem
+ - dynamodb:DeleteItem
+ Resource:
+ - Fn::GetAtt: [ UsersTable, Arn ]
+ environment:
+ USERS_TABLE: ${self:custom.tableName}
+
+functions:
+ api:
+ handler: handler.handler
+ events:
+ - httpApi: '*'
+
+resources:
+ Resources:
+ UsersTable:
+ Type: AWS::DynamoDB::Table
+ Properties:
+ AttributeDefinitions:
+ - AttributeName: userId
+ AttributeType: S
+ KeySchema:
+ - AttributeName: userId
+ KeyType: HASH
+ BillingMode: PAY_PER_REQUEST
+ TableName: ${self:custom.tableName}
diff --git a/aws-node-fetch-file-and-store-in-s3/README.md b/aws-node-fetch-file-and-store-in-s3/README.md
index 64d2b3a32..69e83159b 100644
--- a/aws-node-fetch-file-and-store-in-s3/README.md
+++ b/aws-node-fetch-file-and-store-in-s3/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/ScottBrenner'
authorName: 'Scott Brenner'
authorAvatar: 'https://avatars2.githubusercontent.com/u/416477?v=4&s=140'
diff --git a/aws-node-fetch-file-and-store-in-s3/serverless.yml b/aws-node-fetch-file-and-store-in-s3/serverless.yml
index 817d5c60a..e5382a928 100644
--- a/aws-node-fetch-file-and-store-in-s3/serverless.yml
+++ b/aws-node-fetch-file-and-store-in-s3/serverless.yml
@@ -1,6 +1,6 @@
service: fetch-file-and-store-in-s3
-frameworkVersion: ">=1.1.0"
+frameworkVersion: ">=2.24.0"
custom:
bucket:
@@ -10,12 +10,14 @@ provider:
runtime: nodejs12.x
stage: dev
region: us-west-1
- iamRoleStatements:
- - Effect: Allow
- Action:
- - s3:PutObject
- - s3:PutObjectAcl
- Resource: "arn:aws:s3:::${self:custom.bucket}/*"
+ iam:
+ role:
+ statements:
+ - Effect: Allow
+ Action:
+ - s3:PutObject
+ - s3:PutObjectAcl
+ Resource: "arn:aws:s3:::${self:custom.bucket}/*"
functions:
save:
diff --git a/aws-node-fullstack/README.md b/aws-node-fullstack/README.md
index deefee182..962400bc2 100644
--- a/aws-node-fullstack/README.md
+++ b/aws-node-fullstack/README.md
@@ -4,6 +4,7 @@ description: 'This example demonstrates how to deploy a Fullstack serverless app
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/trilom'
authorName: 'Bryan Killian'
authorAvatar: 'https://avatars0.githubusercontent.com/u/7476973?v=4&s=140'
diff --git a/aws-node-function-compiled-with-babel/README.md b/aws-node-function-compiled-with-babel/README.md
index be848a4ea..99c198d44 100644
--- a/aws-node-function-compiled-with-babel/README.md
+++ b/aws-node-function-compiled-with-babel/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/rupakg'
authorName: 'Rupak Ganguly'
authorAvatar: 'https://avatars0.githubusercontent.com/u/8188?v=4&s=140'
diff --git a/aws-node-github-check/README.md b/aws-node-github-check/README.md
index ff48399eb..7b180a7d4 100644
--- a/aws-node-github-check/README.md
+++ b/aws-node-github-check/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/Fortiz2305'
authorName: 'Francisco Ortiz'
authorAvatar: 'https://avatars0.githubusercontent.com/u/4025821?v=4&s=140'
diff --git a/aws-node-github-webhook-listener/README.md b/aws-node-github-webhook-listener/README.md
index a10abcae6..e9afc80ae 100644
--- a/aws-node-github-webhook-listener/README.md
+++ b/aws-node-github-webhook-listener/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/adambrgmn'
authorName: 'Adam Bergman'
authorAvatar: 'https://avatars1.githubusercontent.com/u/13746650?v=4&s=140'
diff --git a/aws-node-graphql-and-rds/README.md b/aws-node-graphql-and-rds/README.md
index 9fda69198..340f9339c 100644
--- a/aws-node-graphql-and-rds/README.md
+++ b/aws-node-graphql-and-rds/README.md
@@ -5,9 +5,10 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
-authorLink: ’https://github.com/chief-wizard'
-authorName: ‘Chief Wizard’
-authorAvatar: ‘https://avatars3.githubusercontent.com/u/40777040?v=4&s=140
+priority: 1
+authorLink: 'https://github.com/chief-wizard'
+authorName: 'Chief Wizard'
+authorAvatar: 'https://avatars3.githubusercontent.com/u/40777040?v=4&s=140'
-->
# A Simple Serverless GraphQL API for MySQL, Postgres and Aurora
diff --git a/aws-node-graphql-and-rds/resource/PostgreSqlRDSInstance.yml b/aws-node-graphql-and-rds/resource/PostgreSqlRDSInstance.yml
index b174c3a98..a21e4272b 100755
--- a/aws-node-graphql-and-rds/resource/PostgreSqlRDSInstance.yml
+++ b/aws-node-graphql-and-rds/resource/PostgreSqlRDSInstance.yml
@@ -5,10 +5,10 @@ Properties:
MasterUserPassword: ${self:custom.PASSWORD}
AllocatedStorage: 20
DBName: ${self:custom.DB_NAME}
- DBInstanceClass: db.t2.micro
+ DBInstanceClass: db.t4g.small
VPCSecurityGroups:
- !GetAtt ServerlessSecurityGroup.GroupId
DBSubnetGroupName:
Ref: ServerlessSubnetGroup
Engine: postgres
- PubliclyAccessible: true
\ No newline at end of file
+ PubliclyAccessible: true
diff --git a/aws-node-graphql-and-rds/serverless.yml b/aws-node-graphql-and-rds/serverless.yml
index 5d72036a6..c5a3ddd6d 100755
--- a/aws-node-graphql-and-rds/serverless.yml
+++ b/aws-node-graphql-and-rds/serverless.yml
@@ -6,7 +6,8 @@ provider:
stage: dev
memorySize: 256
runtime: nodejs12.x
- role: LambdaRole
+ iam:
+ role: LambdaRole
environment:
#aurora
AURORA_HOST: ${self:custom.AURORA.HOST}
diff --git a/aws-node-graphql-api-with-dynamodb/README.md b/aws-node-graphql-api-with-dynamodb/README.md
index 0cb194300..7722a4826 100644
--- a/aws-node-graphql-api-with-dynamodb/README.md
+++ b/aws-node-graphql-api-with-dynamodb/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 1
authorLink: 'https://github.com/gismoranas'
authorName: 'Gismo Ranas'
authorAvatar: 'https://avatars0.githubusercontent.com/u/5903107?v=4&s=140'
diff --git a/aws-node-graphql-api-with-dynamodb/serverless.yml b/aws-node-graphql-api-with-dynamodb/serverless.yml
index 77056d5f5..0ad20a8c6 100644
--- a/aws-node-graphql-api-with-dynamodb/serverless.yml
+++ b/aws-node-graphql-api-with-dynamodb/serverless.yml
@@ -5,12 +5,14 @@ provider:
runtime: nodejs10.x
environment:
DYNAMODB_TABLE: ${self:service}-${self:provider.stage}
- iamRoleStatements:
- - Effect: Allow
- Action:
- - dynamodb:GetItem
- - dynamodb:UpdateItem
- Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
+ iam:
+ role:
+ statements:
+ - Effect: Allow
+ Action:
+ - dynamodb:GetItem
+ - dynamodb:UpdateItem
+ Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
functions:
query:
diff --git a/aws-node-heroku-postgres/README.md b/aws-node-heroku-postgres/README.md
index 5e1815677..df389a6c1 100644
--- a/aws-node-heroku-postgres/README.md
+++ b/aws-node-heroku-postgres/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/welkie'
authorName: 'Matt Welke'
authorAvatar: 'https://avatars0.githubusercontent.com/u/7719209'
diff --git a/aws-node-http-api-dynamodb-local/.gitignore b/aws-node-http-api-dynamodb-local/.gitignore
new file mode 100644
index 000000000..e0f039d9d
--- /dev/null
+++ b/aws-node-http-api-dynamodb-local/.gitignore
@@ -0,0 +1,2 @@
+.serverless
+node_modules
diff --git a/aws-node-http-api-dynamodb-local/README.md b/aws-node-http-api-dynamodb-local/README.md
new file mode 100644
index 000000000..c1a89aec4
--- /dev/null
+++ b/aws-node-http-api-dynamodb-local/README.md
@@ -0,0 +1,98 @@
+
+# Serverless HTTP API with DynamoDB and offline support
+
+This example demonstrates how to run a service locally, using the
+[serverless-offline](https://github.com/dherault/serverless-offline) plugin. It
+provides an HTTP API to manage Todos stored in a DynamoDB, similar to the
+[aws-node-http-api-dynamodb](https://github.com/serverless/examples/tree/master/aws-node-http-api-dynamodb)
+example. A local DynamoDB instance is provided by the
+[serverless-dynamodb-local](https://github.com/99xt/serverless-dynamodb-local)
+plugin.
+
+## Use-case
+
+Test your service locally, without having to deploy it first.
+
+## Setup
+
+```bash
+npm install
+serverless dynamodb install (or to use a persistent docker dynamodb instead, open a new terminal: cd ./dynamodb && docker-compose up -d)
+serverless offline start
+serverless dynamodb migrate (this imports schema)
+```
+
+## Run service offline
+
+```bash
+serverless offline start
+```
+
+## Usage
+
+You can create, retrieve, update, or delete todos with the following commands:
+
+### Create a Todo
+
+```bash
+curl -X POST -H "Content-Type:application/json" http://localhost:3000/todos --data '{ "text": "Learn Serverless" }'
+```
+
+Example Result:
+```bash
+{"text":"Learn Serverless","id":"ee6490d0-aa11e6-9ede-afdfa051af86","createdAt":1479138570824,"checked":false,"updatedAt":1479138570824}%
+```
+
+### List all Todos
+
+```bash
+curl -H "Content-Type:application/json" http://localhost:3000/todos
+```
+
+Example output:
+```bash
+[{"text":"Deploy my first service","id":"ac90feaa11e6-9ede-afdfa051af86","checked":true,"updatedAt":1479139961304},{"text":"Learn Serverless","id":"206793aa11e6-9ede-afdfa051af86","createdAt":1479139943241,"checked":false,"updatedAt":1479139943241}]%
+```
+
+### Get one Todo
+
+```bash
+# Replace the part with a real id from your todos table
+curl -H "Content-Type:application/json" http://localhost:3000/todos/
+```
+
+Example Result:
+```bash
+{"text":"Learn Serverless","id":"ee6490d0-aa11e6-9ede-afdfa051af86","createdAt":1479138570824,"checked":false,"updatedAt":1479138570824}%
+```
+
+### Update a Todo
+
+```bash
+# Replace the part with a real id from your todos table
+curl -X PUT -H "Content-Type:application/json" http://localhost:3000/todos/ --data '{ "text": "Learn Serverless", "checked": true }'
+```
+
+Example Result:
+```bash
+{"text":"Learn Serverless","id":"ee6490d0-aa11e6-9ede-afdfa051af86","createdAt":1479138570824,"checked":true,"updatedAt":1479138570824}%
+```
+
+### Delete a Todo
+
+```bash
+# Replace the part with a real id from your todos table
+curl -X DELETE -H "Content-Type:application/json" http://localhost:3000/todos/
+```
+
+No output
diff --git a/aws-node-http-api-dynamodb-local/dynamodb/Dockerfile b/aws-node-http-api-dynamodb-local/dynamodb/Dockerfile
new file mode 100644
index 000000000..17c75923e
--- /dev/null
+++ b/aws-node-http-api-dynamodb-local/dynamodb/Dockerfile
@@ -0,0 +1,8 @@
+FROM amazon/dynamodb-local
+
+WORKDIR /home/dynamodblocal
+
+RUN mkdir ./db && chown -R 1000 ./db
+
+CMD ["-jar", "DynamoDBLocal.jar", "-dbPath", "./db", "-sharedDb"]
+VOLUME ["./db"]
diff --git a/aws-node-http-api-dynamodb-local/dynamodb/docker-compose.yml b/aws-node-http-api-dynamodb-local/dynamodb/docker-compose.yml
new file mode 100644
index 000000000..af6720ae2
--- /dev/null
+++ b/aws-node-http-api-dynamodb-local/dynamodb/docker-compose.yml
@@ -0,0 +1,15 @@
+version: "3"
+
+services:
+ dynamodb:
+ build:
+ context: .
+ dockerfile: Dockerfile
+ ports:
+ - 8000:8000
+ volumes:
+ - aws-http-api-dynamodb:/home/dynamodblocal/db
+
+volumes:
+ aws-http-api-dynamodb:
+ driver: local
diff --git a/aws-node-http-api-dynamodb-local/offline/migrations/todos.json b/aws-node-http-api-dynamodb-local/offline/migrations/todos.json
new file mode 100644
index 000000000..aa05790fa
--- /dev/null
+++ b/aws-node-http-api-dynamodb-local/offline/migrations/todos.json
@@ -0,0 +1,21 @@
+{
+ "Table": {
+ "TableName": "serverless-http-api-dynamodb-local-dev",
+ "KeySchema": [
+ {
+ "AttributeName": "id",
+ "KeyType": "HASH"
+ }
+ ],
+ "AttributeDefinitions": [
+ {
+ "AttributeName": "id",
+ "AttributeType": "S"
+ }
+ ],
+ "ProvisionedThroughput": {
+ "ReadCapacityUnits": 1,
+ "WriteCapacityUnits": 1
+ }
+ }
+}
diff --git a/aws-node-http-api-dynamodb-local/package.json b/aws-node-http-api-dynamodb-local/package.json
new file mode 100644
index 000000000..42eeb45f2
--- /dev/null
+++ b/aws-node-http-api-dynamodb-local/package.json
@@ -0,0 +1,16 @@
+{
+ "name": "serverless-http-api-dynamodb-local",
+ "version": "1.0.0",
+ "description": "Serverless HTTP API with DynamoDB and offline support",
+ "repository": "",
+ "author": "Christoph Gysin ",
+ "license": "MIT",
+ "dependencies": {
+ "uuid": "^2.0.3"
+ },
+ "devDependencies": {
+ "aws-sdk": "^2.12.0",
+ "serverless-dynamodb-local": "^0.2.18",
+ "serverless-offline": "^6.8.0"
+ }
+}
diff --git a/aws-node-http-api-dynamodb-local/serverless.yml b/aws-node-http-api-dynamodb-local/serverless.yml
new file mode 100644
index 000000000..bf69bba33
--- /dev/null
+++ b/aws-node-http-api-dynamodb-local/serverless.yml
@@ -0,0 +1,93 @@
+service: serverless-http-api-dynamodb-local
+frameworkVersion: '2'
+
+plugins:
+ - serverless-dynamodb-local
+ - serverless-offline
+
+custom:
+ dynamodb:
+ stages:
+ - dev
+ start:
+ port: 8000
+ inMemory: true
+ migrate: true
+ # Comment if you don't have a DynamoDB running locally
+ noStart: true
+ migration:
+ dir: offline/migrations
+
+provider:
+ name: aws
+ runtime: nodejs12.x
+ lambdaHashingVersion: '20201221'
+ environment:
+ DYNAMODB_TABLE: ${self:service}-${sls:stage}
+ httpApi:
+ cors: true
+ iam:
+ role:
+ statements:
+ - Effect: Allow
+ Action:
+ - dynamodb:Query
+ - dynamodb:Scan
+ - dynamodb:GetItem
+ - dynamodb:PutItem
+ - dynamodb:UpdateItem
+ - dynamodb:DeleteItem
+ Resource: "arn:aws:dynamodb:${aws:region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
+
+functions:
+ create:
+ handler: todos/create.create
+ events:
+ - httpApi:
+ path: /todos
+ method: post
+
+ list:
+ handler: todos/list.list
+ events:
+ - httpApi:
+ path: /todos
+ method: get
+
+ get:
+ handler: todos/get.get
+ events:
+ - httpApi:
+ path: /todos/{id}
+ method: get
+
+ update:
+ handler: todos/update.update
+ events:
+ - httpApi:
+ path: /todos/{id}
+ method: put
+
+ delete:
+ handler: todos/delete.delete
+ events:
+ - httpApi:
+ path: /todos/{id}
+ method: delete
+
+resources:
+ Resources:
+ TodosDynamoDbTable:
+ Type: 'AWS::DynamoDB::Table'
+ DeletionPolicy: Retain
+ Properties:
+ AttributeDefinitions:
+ -
+ AttributeName: id
+ AttributeType: S
+ KeySchema:
+ -
+ AttributeName: id
+ KeyType: HASH
+ BillingMode: PAY_PER_REQUEST
+ TableName: ${self:provider.environment.DYNAMODB_TABLE}
diff --git a/aws-node-http-api-dynamodb-local/todos/create.js b/aws-node-http-api-dynamodb-local/todos/create.js
new file mode 100644
index 000000000..5077cf66f
--- /dev/null
+++ b/aws-node-http-api-dynamodb-local/todos/create.js
@@ -0,0 +1,50 @@
+'use strict';
+
+const uuid = require('uuid');
+const dynamodb = require('./dynamodb');
+
+module.exports.create = (event, context, callback) => {
+ const timestamp = new Date().getTime();
+ const data = JSON.parse(event.body);
+ if (typeof data.text !== 'string') {
+ console.error('Validation Failed');
+ callback(null, {
+ statusCode: 400,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t create the todo item.',
+ });
+ return;
+ }
+
+ const params = {
+ TableName: process.env.DYNAMODB_TABLE,
+ Item: {
+ id: uuid.v1(),
+ text: data.text,
+ checked: false,
+ createdAt: timestamp,
+ updatedAt: timestamp,
+ },
+ };
+
+ // write the todo to the database
+ dynamodb.put(params, (error) => {
+ // handle potential errors
+ if (error) {
+ console.error(error);
+ callback(null, {
+ statusCode: error.statusCode || 501,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t create the todo item.',
+ });
+ return;
+ }
+
+ // create a response
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify(params.Item),
+ };
+ callback(null, response);
+ });
+};
diff --git a/aws-node-http-api-dynamodb-local/todos/delete.js b/aws-node-http-api-dynamodb-local/todos/delete.js
new file mode 100644
index 000000000..60f7dea13
--- /dev/null
+++ b/aws-node-http-api-dynamodb-local/todos/delete.js
@@ -0,0 +1,33 @@
+'use strict';
+
+const dynamodb = require('./dynamodb');
+
+module.exports.delete = (event, context, callback) => {
+ const params = {
+ TableName: process.env.DYNAMODB_TABLE,
+ Key: {
+ id: event.pathParameters.id,
+ },
+ };
+
+ // delete the todo from the database
+ dynamodb.delete(params, (error) => {
+ // handle potential errors
+ if (error) {
+ console.error(error);
+ callback(null, {
+ statusCode: error.statusCode || 501,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t remove the todo item.',
+ });
+ return;
+ }
+
+ // create a response
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify({}),
+ };
+ callback(null, response);
+ });
+};
diff --git a/aws-node-http-api-dynamodb-local/todos/dynamodb.js b/aws-node-http-api-dynamodb-local/todos/dynamodb.js
new file mode 100644
index 000000000..2a08ba9c4
--- /dev/null
+++ b/aws-node-http-api-dynamodb-local/todos/dynamodb.js
@@ -0,0 +1,17 @@
+'use strict';
+
+const AWS = require('aws-sdk'); // eslint-disable-line import/no-extraneous-dependencies
+
+let options = {};
+
+// connect to local DB if running offline
+if (process.env.IS_OFFLINE) {
+ options = {
+ region: 'localhost',
+ endpoint: 'http://localhost:8000',
+ };
+}
+
+const client = new AWS.DynamoDB.DocumentClient(options);
+
+module.exports = client;
diff --git a/aws-node-http-api-dynamodb-local/todos/get.js b/aws-node-http-api-dynamodb-local/todos/get.js
new file mode 100644
index 000000000..cfe50586c
--- /dev/null
+++ b/aws-node-http-api-dynamodb-local/todos/get.js
@@ -0,0 +1,33 @@
+'use strict';
+
+const dynamodb = require('./dynamodb');
+
+module.exports.get = (event, context, callback) => {
+ const params = {
+ TableName: process.env.DYNAMODB_TABLE,
+ Key: {
+ id: event.pathParameters.id,
+ },
+ };
+
+ // fetch todo from the database
+ dynamodb.get(params, (error, result) => {
+ // handle potential errors
+ if (error) {
+ console.error(error);
+ callback(null, {
+ statusCode: error.statusCode || 501,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t fetch the todo item.',
+ });
+ return;
+ }
+
+ // create a response
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify(result.Item),
+ };
+ callback(null, response);
+ });
+};
diff --git a/aws-node-http-api-dynamodb-local/todos/list.js b/aws-node-http-api-dynamodb-local/todos/list.js
new file mode 100644
index 000000000..9592c7498
--- /dev/null
+++ b/aws-node-http-api-dynamodb-local/todos/list.js
@@ -0,0 +1,30 @@
+'use strict';
+
+const dynamodb = require('./dynamodb');
+
+module.exports.list = (event, context, callback) => {
+ const params = {
+ TableName: process.env.DYNAMODB_TABLE,
+ };
+
+ // fetch all todos from the database
+ dynamodb.scan(params, (error, result) => {
+ // handle potential errors
+ if (error) {
+ console.error(error);
+ callback(null, {
+ statusCode: error.statusCode || 501,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t fetch the todo item.',
+ });
+ return;
+ }
+
+ // create a response
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify(result.Items),
+ };
+ callback(null, response);
+ });
+};
diff --git a/aws-node-http-api-dynamodb-local/todos/update.js b/aws-node-http-api-dynamodb-local/todos/update.js
new file mode 100644
index 000000000..5a0106fa1
--- /dev/null
+++ b/aws-node-http-api-dynamodb-local/todos/update.js
@@ -0,0 +1,57 @@
+'use strict';
+
+const dynamodb = require('./dynamodb');
+
+module.exports.update = (event, context, callback) => {
+ const timestamp = new Date().getTime();
+ const data = JSON.parse(event.body);
+
+ // validation
+ if (typeof data.text !== 'string' || typeof data.checked !== 'boolean') {
+ console.error('Validation Failed');
+ callback(null, {
+ statusCode: 400,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t update the todo item.',
+ });
+ return;
+ }
+
+ const params = {
+ TableName: process.env.DYNAMODB_TABLE,
+ Key: {
+ id: event.pathParameters.id,
+ },
+ ExpressionAttributeNames: {
+ '#todo_text': 'text',
+ },
+ ExpressionAttributeValues: {
+ ':text': data.text,
+ ':checked': data.checked,
+ ':updatedAt': timestamp,
+ },
+ UpdateExpression: 'SET #todo_text = :text, checked = :checked, updatedAt = :updatedAt',
+ ReturnValues: 'ALL_NEW',
+ };
+
+ // update the todo in the database
+ dynamodb.update(params, (error, result) => {
+ // handle potential errors
+ if (error) {
+ console.error(error);
+ callback(null, {
+ statusCode: error.statusCode || 501,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t update the todo item.',
+ });
+ return;
+ }
+
+ // create a response
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify(result.Attributes),
+ };
+ callback(null, response);
+ });
+};
diff --git a/aws-node-http-api-dynamodb/.gitignore b/aws-node-http-api-dynamodb/.gitignore
new file mode 100644
index 000000000..2c4448065
--- /dev/null
+++ b/aws-node-http-api-dynamodb/.gitignore
@@ -0,0 +1,2 @@
+node_modules
+.serverless
diff --git a/aws-node-http-api-dynamodb/README.md b/aws-node-http-api-dynamodb/README.md
new file mode 100644
index 000000000..5c9197046
--- /dev/null
+++ b/aws-node-http-api-dynamodb/README.md
@@ -0,0 +1,148 @@
+
+# Serverless HTTP API
+
+This example demonstrates how to setup a [RESTful Web Services](https://en.wikipedia.org/wiki/Representational_state_transfer#Applied_to_web_services) allowing you to create, list, get, update and delete Todos. DynamoDB is used to store the data. This is just an example and of course you could use any data storage as a backend.
+
+## Structure
+
+This service has a separate directory for all the todo operations. For each operation exactly one file exists e.g. `todos/delete.js`. In each of these files there is exactly one function which is directly attached to `module.exports`.
+
+The idea behind the `todos` directory is that in case you want to create a service containing multiple resources e.g. users, notes, comments you could do so in the same service. While this is certainly possible you might consider creating a separate service for each resource. It depends on the use-case and your preference.
+
+## Use-cases
+
+- API for a Web Application
+- API for a Mobile Application
+
+## Setup
+
+```bash
+npm install
+```
+
+## Deploy
+
+In order to deploy the endpoint simply run
+
+```bash
+serverless deploy
+```
+
+The expected result should be similar to:
+
+```bash
+Serverless: Packaging service…
+Serverless: Uploading CloudFormation file to S3…
+Serverless: Uploading service .zip file to S3…
+Serverless: Updating Stack…
+Serverless: Checking Stack update progress…
+Serverless: Stack update finished…
+
+Service Information
+service: serverless-http-api-dynamodb
+stage: dev
+region: us-east-1
+api keys:
+ None
+endpoints:
+ POST - https://45wf34z5yf.execute-api.us-east-1.amazonaws.com/todos
+ GET - https://45wf34z5yf.execute-api.us-east-1.amazonaws.com/todos
+ GET - https://45wf34z5yf.execute-api.us-east-1.amazonaws.com/todos/{id}
+ PUT - https://45wf34z5yf.execute-api.us-east-1.amazonaws.com/todos/{id}
+ DELETE - https://45wf34z5yf.execute-api.us-east-1.amazonaws.com/todos/{id}
+functions:
+ serverless-http-api-dynamodb-dev-update: arn:aws:lambda:us-east-1:488110005556:function:serverless-http-api-dynamodb-dev-update
+ serverless-http-api-dynamodb-dev-get: arn:aws:lambda:us-east-1:488110005556:function:serverless-http-api-dynamodb-dev-get
+ serverless-http-api-dynamodb-dev-list: arn:aws:lambda:us-east-1:488110005556:function:serverless-http-api-dynamodb-dev-list
+ serverless-http-api-dynamodb-dev-create: arn:aws:lambda:us-east-1:488110005556:function:serverless-http-api-dynamodb-dev-create
+ serverless-http-api-dynamodb-dev-delete: arn:aws:lambda:us-east-1:488110005556:function:serverless-http-api-dynamodb-dev-delete
+```
+
+## Usage
+
+You can create, retrieve, update, or delete todos with the following commands:
+
+### Create a Todo
+
+```bash
+curl -X POST https://XXXXXXX.execute-api.us-east-1.amazonaws.com/todos --data '{ "text": "Learn Serverless" }'
+```
+
+Example Result:
+```bash
+{"text":"Learn Serverless","id":"ee6490d0-aa11e6-9ede-afdfa051af86","createdAt":1479138570824,"checked":false,"updatedAt":1479138570824}%
+```
+
+### List all Todos
+
+```bash
+curl https://XXXXXXX.execute-api.us-east-1.amazonaws.com/todos
+```
+
+Example output:
+```bash
+[{"text":"Deploy my first service","id":"ac90feaa11e6-9ede-afdfa051af86","checked":true,"updatedAt":1479139961304},{"text":"Learn Serverless","id":"206793aa11e6-9ede-afdfa051af86","createdAt":1479139943241,"checked":false,"updatedAt":1479139943241}]%
+```
+
+### Get one Todo
+
+```bash
+# Replace the part with a real id from your todos table
+curl https://XXXXXXX.execute-api.us-east-1.amazonaws.com/todos/
+```
+
+Example Result:
+```bash
+{"text":"Learn Serverless","id":"ee6490d0-aa11e6-9ede-afdfa051af86","createdAt":1479138570824,"checked":false,"updatedAt":1479138570824}%
+```
+
+### Update a Todo
+
+```bash
+# Replace the part with a real id from your todos table
+curl -X PUT https://XXXXXXX.execute-api.us-east-1.amazonaws.com/todos/ --data '{ "text": "Learn Serverless", "checked": true }'
+```
+
+Example Result:
+```bash
+{"text":"Learn Serverless","id":"ee6490d0-aa11e6-9ede-afdfa051af86","createdAt":1479138570824,"checked":true,"updatedAt":1479138570824}%
+```
+
+### Delete a Todo
+
+```bash
+# Replace the part with a real id from your todos table
+curl -X DELETE https://XXXXXXX.execute-api.us-east-1.amazonaws.com/todos/
+```
+
+No output
+
+## Scaling
+
+### AWS Lambda
+
+By default, AWS Lambda limits the total concurrent executions across all functions within a given region to 100. The default limit is a safety limit that protects you from costs due to potential runaway or recursive functions during initial development and testing. To increase this limit above the default, follow the steps in [To request a limit increase for concurrent executions](http://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html#increase-concurrent-executions-limit).
+
+### DynamoDB
+
+When you create a table, you specify how much provisioned throughput capacity you want to reserve for reads and writes. DynamoDB will reserve the necessary resources to meet your throughput needs while ensuring consistent, low-latency performance. You can change the provisioned throughput and increasing or decreasing capacity as needed.
+
+This is can be done via settings in the `serverless.yml`.
+
+```yaml
+ ProvisionedThroughput:
+ ReadCapacityUnits: 1
+ WriteCapacityUnits: 1
+```
+
+In case you expect a lot of traffic fluctuation we recommend to checkout this guide on how to auto scale DynamoDB [https://aws.amazon.com/blogs/aws/auto-scale-dynamodb-with-dynamic-dynamodb/](https://aws.amazon.com/blogs/aws/auto-scale-dynamodb-with-dynamic-dynamodb/)
diff --git a/aws-node-http-api-dynamodb/package.json b/aws-node-http-api-dynamodb/package.json
new file mode 100644
index 000000000..55d554043
--- /dev/null
+++ b/aws-node-http-api-dynamodb/package.json
@@ -0,0 +1,10 @@
+{
+ "name": "serverless-http-api-dynamodb",
+ "version": "1.0.0",
+ "description": "Serverless CRUD service exposing a REST HTTP interface",
+ "author": "",
+ "license": "MIT",
+ "dependencies": {
+ "uuid": "^2.0.3"
+ }
+}
diff --git a/aws-node-http-api-dynamodb/serverless.yml b/aws-node-http-api-dynamodb/serverless.yml
new file mode 100644
index 000000000..d30d42ca0
--- /dev/null
+++ b/aws-node-http-api-dynamodb/serverless.yml
@@ -0,0 +1,76 @@
+service: serverless-http-api-dynamodb
+frameworkVersion: '2'
+
+provider:
+ name: aws
+ runtime: nodejs12.x
+ lambdaHashingVersion: '20201221'
+ environment:
+ DYNAMODB_TABLE: ${self:service}-${sls:stage}
+ httpApi:
+ cors: true
+ iam:
+ role:
+ statements:
+ - Effect: Allow
+ Action:
+ - dynamodb:Query
+ - dynamodb:Scan
+ - dynamodb:GetItem
+ - dynamodb:PutItem
+ - dynamodb:UpdateItem
+ - dynamodb:DeleteItem
+ Resource: "arn:aws:dynamodb:${aws:region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
+
+functions:
+ create:
+ handler: todos/create.create
+ events:
+ - httpApi:
+ path: /todos
+ method: post
+
+ list:
+ handler: todos/list.list
+ events:
+ - httpApi:
+ path: /todos
+ method: get
+
+ get:
+ handler: todos/get.get
+ events:
+ - httpApi:
+ path: /todos/{id}
+ method: get
+
+ update:
+ handler: todos/update.update
+ events:
+ - httpApi:
+ path: /todos/{id}
+ method: put
+
+ delete:
+ handler: todos/delete.delete
+ events:
+ - httpApi:
+ path: /todos/{id}
+ method: delete
+
+resources:
+ Resources:
+ TodosDynamoDbTable:
+ Type: 'AWS::DynamoDB::Table'
+ DeletionPolicy: Retain
+ Properties:
+ AttributeDefinitions:
+ -
+ AttributeName: id
+ AttributeType: S
+ KeySchema:
+ -
+ AttributeName: id
+ KeyType: HASH
+ BillingMode: PAY_PER_REQUEST
+ TableName: ${self:provider.environment.DYNAMODB_TABLE}
diff --git a/aws-node-http-api-dynamodb/todos/create.js b/aws-node-http-api-dynamodb/todos/create.js
new file mode 100644
index 000000000..81ed8df9a
--- /dev/null
+++ b/aws-node-http-api-dynamodb/todos/create.js
@@ -0,0 +1,52 @@
+'use strict';
+
+const uuid = require('uuid');
+const AWS = require('aws-sdk'); // eslint-disable-line import/no-extraneous-dependencies
+
+const dynamoDb = new AWS.DynamoDB.DocumentClient();
+
+module.exports.create = (event, context, callback) => {
+ const timestamp = new Date().getTime();
+ const data = JSON.parse(event.body);
+ if (typeof data.text !== 'string') {
+ console.error('Validation Failed');
+ callback(null, {
+ statusCode: 400,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t create the todo item.',
+ });
+ return;
+ }
+
+ const params = {
+ TableName: process.env.DYNAMODB_TABLE,
+ Item: {
+ id: uuid.v1(),
+ text: data.text,
+ checked: false,
+ createdAt: timestamp,
+ updatedAt: timestamp,
+ },
+ };
+
+ // write the todo to the database
+ dynamoDb.put(params, (error) => {
+ // handle potential errors
+ if (error) {
+ console.error(error);
+ callback(null, {
+ statusCode: error.statusCode || 501,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t create the todo item.',
+ });
+ return;
+ }
+
+ // create a response
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify(params.Item),
+ };
+ callback(null, response);
+ });
+};
diff --git a/aws-node-http-api-dynamodb/todos/delete.js b/aws-node-http-api-dynamodb/todos/delete.js
new file mode 100644
index 000000000..4192ac737
--- /dev/null
+++ b/aws-node-http-api-dynamodb/todos/delete.js
@@ -0,0 +1,35 @@
+'use strict';
+
+const AWS = require('aws-sdk'); // eslint-disable-line import/no-extraneous-dependencies
+
+const dynamoDb = new AWS.DynamoDB.DocumentClient();
+
+module.exports.delete = (event, context, callback) => {
+ const params = {
+ TableName: process.env.DYNAMODB_TABLE,
+ Key: {
+ id: event.pathParameters.id,
+ },
+ };
+
+ // delete the todo from the database
+ dynamoDb.delete(params, (error) => {
+ // handle potential errors
+ if (error) {
+ console.error(error);
+ callback(null, {
+ statusCode: error.statusCode || 501,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t remove the todo item.',
+ });
+ return;
+ }
+
+ // create a response
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify({}),
+ };
+ callback(null, response);
+ });
+};
diff --git a/aws-node-http-api-dynamodb/todos/get.js b/aws-node-http-api-dynamodb/todos/get.js
new file mode 100644
index 000000000..4cc34d307
--- /dev/null
+++ b/aws-node-http-api-dynamodb/todos/get.js
@@ -0,0 +1,35 @@
+'use strict';
+
+const AWS = require('aws-sdk'); // eslint-disable-line import/no-extraneous-dependencies
+
+const dynamoDb = new AWS.DynamoDB.DocumentClient();
+
+module.exports.get = (event, context, callback) => {
+ const params = {
+ TableName: process.env.DYNAMODB_TABLE,
+ Key: {
+ id: event.pathParameters.id,
+ },
+ };
+
+ // fetch todo from the database
+ dynamoDb.get(params, (error, result) => {
+ // handle potential errors
+ if (error) {
+ console.error(error);
+ callback(null, {
+ statusCode: error.statusCode || 501,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t fetch the todo item.',
+ });
+ return;
+ }
+
+ // create a response
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify(result.Item),
+ };
+ callback(null, response);
+ });
+};
diff --git a/aws-node-http-api-dynamodb/todos/list.js b/aws-node-http-api-dynamodb/todos/list.js
new file mode 100644
index 000000000..5818246cd
--- /dev/null
+++ b/aws-node-http-api-dynamodb/todos/list.js
@@ -0,0 +1,31 @@
+'use strict';
+
+const AWS = require('aws-sdk'); // eslint-disable-line import/no-extraneous-dependencies
+
+const dynamoDb = new AWS.DynamoDB.DocumentClient();
+const params = {
+ TableName: process.env.DYNAMODB_TABLE,
+};
+
+module.exports.list = (event, context, callback) => {
+ // fetch all todos from the database
+ dynamoDb.scan(params, (error, result) => {
+ // handle potential errors
+ if (error) {
+ console.error(error);
+ callback(null, {
+ statusCode: error.statusCode || 501,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t fetch the todos.',
+ });
+ return;
+ }
+
+ // create a response
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify(result.Items),
+ };
+ callback(null, response);
+ });
+};
diff --git a/aws-node-http-api-dynamodb/todos/update.js b/aws-node-http-api-dynamodb/todos/update.js
new file mode 100644
index 000000000..c852c6202
--- /dev/null
+++ b/aws-node-http-api-dynamodb/todos/update.js
@@ -0,0 +1,59 @@
+'use strict';
+
+const AWS = require('aws-sdk'); // eslint-disable-line import/no-extraneous-dependencies
+
+const dynamoDb = new AWS.DynamoDB.DocumentClient();
+
+module.exports.update = (event, context, callback) => {
+ const timestamp = new Date().getTime();
+ const data = JSON.parse(event.body);
+
+ // validation
+ if (typeof data.text !== 'string' || typeof data.checked !== 'boolean') {
+ console.error('Validation Failed');
+ callback(null, {
+ statusCode: 400,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t update the todo item.',
+ });
+ return;
+ }
+
+ const params = {
+ TableName: process.env.DYNAMODB_TABLE,
+ Key: {
+ id: event.pathParameters.id,
+ },
+ ExpressionAttributeNames: {
+ '#todo_text': 'text',
+ },
+ ExpressionAttributeValues: {
+ ':text': data.text,
+ ':checked': data.checked,
+ ':updatedAt': timestamp,
+ },
+ UpdateExpression: 'SET #todo_text = :text, checked = :checked, updatedAt = :updatedAt',
+ ReturnValues: 'ALL_NEW',
+ };
+
+ // update the todo in the database
+ dynamoDb.update(params, (error, result) => {
+ // handle potential errors
+ if (error) {
+ console.error(error);
+ callback(null, {
+ statusCode: error.statusCode || 501,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t fetch the todo item.',
+ });
+ return;
+ }
+
+ // create a response
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify(result.Attributes),
+ };
+ callback(null, response);
+ });
+};
diff --git a/aws-node-http-api-mongodb/.gitignore b/aws-node-http-api-mongodb/.gitignore
new file mode 100644
index 000000000..e0f039d9d
--- /dev/null
+++ b/aws-node-http-api-mongodb/.gitignore
@@ -0,0 +1,2 @@
+.serverless
+node_modules
diff --git a/aws-node-http-api-mongodb/README.md b/aws-node-http-api-mongodb/README.md
new file mode 100644
index 000000000..94ed4b780
--- /dev/null
+++ b/aws-node-http-api-mongodb/README.md
@@ -0,0 +1,89 @@
+
+
+# Serverless MongoDB HTTP API with Mongoose and Bluebird Promises
+
+This example demonstrate how to use a MongoDB database with aws and serverless.
+
+Using Mongoose ODM and Bluebird for Promises.
+
+## Use Cases
+
+- NoSQL CRUD API
+
+## Setup
+
+```
+npm install
+serverless deploy
+```
+
+## Usage
+
+In `handler.js` update the `mongoString` with your mongoDB url.
+
+*Create*
+
+```bash
+curl -XPOST -H "Content-type: application/json" -d '{
+ "name" : "John",
+ "firstname" : "Doe",
+ "city" : "Toronto",
+ "birth" : "01/01/1990"
+}' 'https://2c8cx5whk0.execute-api.us-east-1.amazonaws.com/user/'
+```
+```json
+{"id": "590b52ff086041000142cedd"}
+```
+
+*READ*
+
+```bash
+curl -XGET -H "Content-type: application/json" 'https://2c8cx5whk0.execute-api.us-east-1.amazonaws.com/user/590b52ff086041000142cedd'
+```
+```json
+[
+ {
+ "_id": "5905e2fbdb55f20001334b3e",
+ "name": "John",
+ "firstname": "Doe",
+ "birth": null,
+ "city": "Toronto",
+ "ip": "01/01/1990",
+ "__v": 0
+ }
+]
+```
+
+*UPDATE*
+
+```bash
+curl -XPUT -H "Content-type: application/json" -d '{
+ "name" : "William",
+ "firstname" : "Smith",
+ "city" : "Miami",
+ "birth" : "01/01/2000"
+}' 'https://2c8cx5whk0.execute-api.us-east-1.amazonaws.com/user/590b52ff086041000142cedd'
+```
+```json
+"Ok"
+```
+
+*DELETE*
+
+```bash
+curl -XDELETE -H "Content-type: application/json" 'https://2c8cx5whk0.execute-api.us-east-1.amazonaws.com/user/590b52ff086041000142cedd'
+```
+
+```json
+"Ok"
+```
diff --git a/aws-node-http-api-mongodb/handler.js b/aws-node-http-api-mongodb/handler.js
new file mode 100644
index 000000000..6646222f0
--- /dev/null
+++ b/aws-node-http-api-mongodb/handler.js
@@ -0,0 +1,106 @@
+const mongoose = require('mongoose');
+const Promise = require('bluebird');
+const validator = require('validator');
+const UserModel = require('./model/User.js');
+
+mongoose.Promise = Promise;
+
+const mongoString = ''; // MongoDB Url
+
+const createErrorResponse = (statusCode, message) => ({
+ statusCode: statusCode || 501,
+ headers: { 'Content-Type': 'text/plain' },
+ body: message || 'Incorrect id',
+});
+
+const dbExecute = (db, fn) => db.then(fn).finally(() => db.close());
+
+function dbConnectAndExecute(dbUrl, fn) {
+ return dbExecute(mongoose.connect(dbUrl, { useMongoClient: true }), fn);
+}
+
+module.exports.user = (event, context, callback) => {
+ if (!validator.isAlphanumeric(event.pathParameters.id)) {
+ callback(null, createErrorResponse(400, 'Incorrect id'));
+ return;
+ }
+
+ dbConnectAndExecute(mongoString, () => (
+ UserModel
+ .find({ _id: event.pathParameters.id })
+ .then(user => callback(null, { statusCode: 200, body: JSON.stringify(user) }))
+ .catch(err => callback(null, createErrorResponse(err.statusCode, err.message)))
+ ));
+};
+
+
+module.exports.createUser = (event, context, callback) => {
+ const data = JSON.parse(event.body);
+
+ const user = new UserModel({
+ name: data.name,
+ firstname: data.firstname,
+ birth: data.birth,
+ city: data.city,
+ ip: event.requestContext.identity.sourceIp,
+ });
+
+ if (user.validateSync()) {
+ callback(null, createErrorResponse(400, 'Incorrect user data'));
+ return;
+ }
+
+ dbConnectAndExecute(mongoString, () => (
+ user
+ .save()
+ .then(() => callback(null, {
+ statusCode: 200,
+ body: JSON.stringify({ id: user.id }),
+ }))
+ .catch(err => callback(null, createErrorResponse(err.statusCode, err.message)))
+ ));
+};
+
+module.exports.deleteUser = (event, context, callback) => {
+ if (!validator.isAlphanumeric(event.pathParameters.id)) {
+ callback(null, createErrorResponse(400, 'Incorrect id'));
+ return;
+ }
+
+ dbConnectAndExecute(mongoString, () => (
+ UserModel
+ .remove({ _id: event.pathParameters.id })
+ .then(() => callback(null, { statusCode: 200, body: JSON.stringify('Ok') }))
+ .catch(err => callback(null, createErrorResponse(err.statusCode, err.message)))
+ ));
+};
+
+module.exports.updateUser = (event, context, callback) => {
+ const data = JSON.parse(event.body);
+ const id = event.pathParameters.id;
+
+ if (!validator.isAlphanumeric(id)) {
+ callback(null, createErrorResponse(400, 'Incorrect id'));
+ return;
+ }
+
+ const user = new UserModel({
+ _id: id,
+ name: data.name,
+ firstname: data.firstname,
+ birth: data.birth,
+ city: data.city,
+ ip: event.requestContext.identity.sourceIp,
+ });
+
+ if (user.validateSync()) {
+ callback(null, createErrorResponse(400, 'Incorrect parameter'));
+ return;
+ }
+
+ dbConnectAndExecute(mongoString, () => (
+ UserModel.findByIdAndUpdate(id, user)
+ .then(() => callback(null, { statusCode: 200, body: JSON.stringify('Ok') }))
+ .catch(err => callback(err, createErrorResponse(err.statusCode, err.message)))
+ ));
+};
diff --git a/aws-node-http-api-mongodb/model/User.js b/aws-node-http-api-mongodb/model/User.js
new file mode 100644
index 000000000..9970fa73a
--- /dev/null
+++ b/aws-node-http-api-mongodb/model/User.js
@@ -0,0 +1,47 @@
+const mongoose = require('mongoose');
+const validator = require('validator');
+
+const model = mongoose.model('User', {
+ name: {
+ type: String,
+ required: true,
+ validate: {
+ validator(name) {
+ return validator.isAlphanumeric(name);
+ },
+ },
+ },
+ firstname: {
+ type: String,
+ required: true,
+ validate: {
+ validator(firstname) {
+ return validator.isAlphanumeric(firstname);
+ },
+ },
+ },
+ birth: {
+ type: Date,
+ required: true,
+ },
+ city: {
+ type: String,
+ required: true,
+ validate: {
+ validator(city) {
+ return validator.isAlphanumeric(city);
+ },
+ },
+ },
+ ip: {
+ type: String,
+ required: true,
+ validate: {
+ validator(ip) {
+ return validator.isIP(ip);
+ },
+ },
+ },
+});
+
+module.exports = model;
diff --git a/aws-node-http-api-mongodb/package.json b/aws-node-http-api-mongodb/package.json
new file mode 100644
index 000000000..d05af2b36
--- /dev/null
+++ b/aws-node-http-api-mongodb/package.json
@@ -0,0 +1,13 @@
+{
+ "name": "serverless-http-api-mongodb",
+ "version": "1.0.0",
+ "description": "Serverless HTTP API with MongoDB using Mongoose and Bluebird",
+ "main": "handler.js",
+ "dependencies": {
+ "bluebird": "^3.5.0",
+ "mongoose": "^4.9.6",
+ "validator": "^7.0.0"
+ },
+ "author": "Quentin Homareau ",
+ "license": "MIT"
+}
diff --git a/aws-node-http-api-mongodb/serverless.yml b/aws-node-http-api-mongodb/serverless.yml
new file mode 100644
index 000000000..32eb2640a
--- /dev/null
+++ b/aws-node-http-api-mongodb/serverless.yml
@@ -0,0 +1,38 @@
+service: serverless-http-api-mongodb
+frameworkVersion: '2'
+
+provider:
+ name: aws
+ runtime: nodejs12.x
+ lambdaHashingVersion: 20201221
+ httpApi:
+ cors: true
+
+functions:
+ createUser:
+ handler: handler.createUser
+ events:
+ - httpApi:
+ path: /user
+ method: post
+
+ updateUser:
+ handler: handler.updateUser
+ events:
+ - httpApi:
+ path: /user/{id}
+ method: put
+
+ deleteUser:
+ handler: handler.deleteUser
+ events:
+ - httpApi:
+ path: /user/{id}
+ method: delete
+
+ user:
+ handler: handler.user
+ events:
+ - httpApi:
+ path: /user/{id}
+ method: get
diff --git a/aws-node-http-api-typescript-dynamodb/.gitignore b/aws-node-http-api-typescript-dynamodb/.gitignore
new file mode 100644
index 000000000..a6c7c2852
--- /dev/null
+++ b/aws-node-http-api-typescript-dynamodb/.gitignore
@@ -0,0 +1 @@
+*.js
diff --git a/aws-node-http-api-typescript-dynamodb/README.md b/aws-node-http-api-typescript-dynamodb/README.md
new file mode 100644
index 000000000..799019fca
--- /dev/null
+++ b/aws-node-http-api-typescript-dynamodb/README.md
@@ -0,0 +1,80 @@
+
+
+# Introduction
+
+TypeScript (ts) offers type safety which is helpful when working with the AWS SDK, which comes with ts definitions (d.ts)
+
+# compiling
+
+You can compile the ts files in this directory by 1st installing typescript via
+
+`npm install -g typescript`
+
+then
+
+`npm i`
+
+You can then run the compiler by running `tsc` in this directory. It will pull the settings from .tsconfig and extra @types
+from package.json. The output create.js file is what will be uploaded by serverless.
+
+For brevity, I have just demonstrated this to match with the todos/create.js, todos/list.js, todos/get.js and todos/update.js lambda function
+
+## Usage
+
+You can create, retrieve, update, or delete todos with the following commands:
+
+### Create a Todo
+
+```bash
+curl -X POST https://XXXXXXX.execute-api.us-east-1.amazonaws.com/todos --data '{ "text": "Learn Serverless" }'
+```
+
+Example Result:
+```bash
+{"text":"Learn Serverless","id":"ee6490d0-aa11e6-9ede-afdfa051af86","createdAt":1479138570824,"checked":false,"updatedAt":1479138570824}%
+```
+
+### List all Todos
+
+```bash
+curl https://XXXXXXX.execute-api.us-east-1.amazonaws.com/todos
+```
+
+Example output:
+```bash
+[{"text":"Deploy my first service","id":"ac90feaa11e6-9ede-afdfa051af86","checked":true,"updatedAt":1479139961304},{"text":"Learn Serverless","id":"206793aa11e6-9ede-afdfa051af86","createdAt":1479139943241,"checked":false,"updatedAt":1479139943241}]%
+```
+
+### Get one Todo
+
+```bash
+# Replace the part with a real id from your todos table
+curl https://XXXXXXX.execute-api.us-east-1.amazonaws.com/todos/
+```
+
+Example Result:
+```bash
+{"text":"Learn Serverless","id":"ee6490d0-aa11e6-9ede-afdfa051af86","createdAt":1479138570824,"checked":false,"updatedAt":1479138570824}%
+```
+
+### Update a Todo
+
+```bash
+# Replace the part with a real id from your todos table
+curl -X PUT https://XXXXXXX.execute-api.us-east-1.amazonaws.com/todos/ --data '{ "text": "Learn Serverless", "checked": true }'
+```
+
+Example Result:
+```bash
+{"text":"Learn Serverless","id":"ee6490d0-aa11e6-9ede-afdfa051af86","createdAt":1479138570824,"checked":true,"updatedAt":1479138570824}%
+```
diff --git a/aws-node-http-api-typescript-dynamodb/package.json b/aws-node-http-api-typescript-dynamodb/package.json
new file mode 100644
index 000000000..80ca85df5
--- /dev/null
+++ b/aws-node-http-api-typescript-dynamodb/package.json
@@ -0,0 +1,24 @@
+{
+ "name": "serverless-http-api-typescript-dynamodb",
+ "version": "0.0.0",
+ "description": "",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1",
+ "watch": "tsc -w",
+ "lint": "tslint '*.ts'"
+ },
+ "keywords": [],
+ "author": "",
+ "license": "ISC",
+ "devDependencies": {
+ "@types/aws-sdk": "0.0.42",
+ "@types/node": "^7.0.5",
+ "tslint": "^5.5.0",
+ "tslint-config-standard": "^6.0.1",
+ "typescript": "^2.4.2"
+ },
+ "dependencies": {
+ "uuid": "^3.1.0"
+ }
+}
diff --git a/aws-node-http-api-typescript-dynamodb/serverless.yml b/aws-node-http-api-typescript-dynamodb/serverless.yml
new file mode 100644
index 000000000..590a512bb
--- /dev/null
+++ b/aws-node-http-api-typescript-dynamodb/serverless.yml
@@ -0,0 +1,69 @@
+service: serverless-http-api-typescript-dynamodb
+frameworkVersion: '2'
+
+provider:
+ name: aws
+ runtime: nodejs12.x
+ lambdaHashingVersion: '20201221'
+ environment:
+ DYNAMODB_TABLE: ${self:service}-${sls:stage}
+ httpApi:
+ cors: true
+ iam:
+ role:
+ statements:
+ - Effect: Allow
+ Action:
+ - dynamodb:Query
+ - dynamodb:Scan
+ - dynamodb:GetItem
+ - dynamodb:PutItem
+ - dynamodb:UpdateItem
+ - dynamodb:DeleteItem
+ Resource: "arn:aws:dynamodb:${aws:region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
+
+functions:
+ create:
+ handler: todos/create.create
+ events:
+ - httpApi:
+ path: /todos
+ method: post
+
+ list:
+ handler: todos/list.list
+ events:
+ - httpApi:
+ path: /todos
+ method: get
+
+ get:
+ handler: todos/get.get
+ events:
+ - httpApi:
+ path: /todos/{id}
+ method: get
+
+ update:
+ handler: todos/update.update
+ events:
+ - httpApi:
+ path: /todos/{id}
+ method: put
+
+resources:
+ Resources:
+ TodosDynamoDbTable:
+ Type: 'AWS::DynamoDB::Table'
+ DeletionPolicy: Retain
+ Properties:
+ AttributeDefinitions:
+ -
+ AttributeName: id
+ AttributeType: S
+ KeySchema:
+ -
+ AttributeName: id
+ KeyType: HASH
+ BillingMode: PAY_PER_REQUEST
+ TableName: ${self:provider.environment.DYNAMODB_TABLE}
diff --git a/aws-node-http-api-typescript-dynamodb/todos/create.ts b/aws-node-http-api-typescript-dynamodb/todos/create.ts
new file mode 100644
index 000000000..f86d01cfc
--- /dev/null
+++ b/aws-node-http-api-typescript-dynamodb/todos/create.ts
@@ -0,0 +1,45 @@
+'use strict'
+
+import * as uuid from 'uuid'
+
+import { DynamoDB } from 'aws-sdk'
+
+const dynamoDb = new DynamoDB.DocumentClient()
+
+module.exports.create = (event, context, callback) => {
+ const timestamp = new Date().getTime()
+ const data = JSON.parse(event.body)
+ if (typeof data.text !== 'string') {
+ console.error('Validation Failed')
+ callback(new Error('Couldn\'t create the todo item.'))
+ return
+ }
+
+ const params = {
+ TableName: process.env.DYNAMODB_TABLE,
+ Item: {
+ id: uuid.v1(),
+ text: data.text,
+ checked: false,
+ createdAt: timestamp,
+ updatedAt: timestamp
+ }
+ }
+
+ // write the todo to the database
+ dynamoDb.put(params, (error, result) => {
+ // handle potential errors
+ if (error) {
+ console.error(error)
+ callback(new Error('Couldn\'t create the todo item.'))
+ return
+ }
+
+ // create a response
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify(params.Item)
+ }
+ callback(null, response)
+ })
+}
diff --git a/aws-node-http-api-typescript-dynamodb/todos/get.ts b/aws-node-http-api-typescript-dynamodb/todos/get.ts
new file mode 100644
index 000000000..fa00764b7
--- /dev/null
+++ b/aws-node-http-api-typescript-dynamodb/todos/get.ts
@@ -0,0 +1,36 @@
+'use strict';
+
+import { DynamoDB } from 'aws-sdk'
+
+const dynamoDb = new DynamoDB.DocumentClient()
+
+
+module.exports.get = (event, context, callback) => {
+ const params = {
+ TableName: process.env.DYNAMODB_TABLE,
+ Key: {
+ id: event.pathParameters.id,
+ },
+ };
+
+ // fetch todo from the database
+ dynamoDb.get(params, (error, result) => {
+ // handle potential errors
+ if (error) {
+ console.error(error);
+ callback(null, {
+ statusCode: error.statusCode || 501,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t fetch the todo item.',
+ });
+ return;
+ }
+
+ // create a response
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify(result.Item),
+ };
+ callback(null, response);
+ });
+};
\ No newline at end of file
diff --git a/aws-node-http-api-typescript-dynamodb/todos/list.ts b/aws-node-http-api-typescript-dynamodb/todos/list.ts
new file mode 100644
index 000000000..7b3ea316e
--- /dev/null
+++ b/aws-node-http-api-typescript-dynamodb/todos/list.ts
@@ -0,0 +1,32 @@
+'use strict';
+
+import { DynamoDB } from 'aws-sdk'
+
+const dynamoDb = new DynamoDB.DocumentClient()
+const params = {
+ TableName: process.env.DYNAMODB_TABLE,
+};
+
+module.exports.list = (event, context, callback) => {
+ // fetch all todos from the database
+ // For production workloads you should design your tables and indexes so that your applications can use Query instead of Scan.
+ dynamoDb.scan(params, (error, result) => {
+ // handle potential errors
+ if (error) {
+ console.error(error);
+ callback(null, {
+ statusCode: error.statusCode || 501,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t fetch the todo items.',
+ });
+ return;
+ }
+
+ // create a response
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify(result.Items),
+ };
+ callback(null, response);
+ });
+};
diff --git a/aws-node-http-api-typescript-dynamodb/todos/update.ts b/aws-node-http-api-typescript-dynamodb/todos/update.ts
new file mode 100644
index 000000000..8b3788141
--- /dev/null
+++ b/aws-node-http-api-typescript-dynamodb/todos/update.ts
@@ -0,0 +1,59 @@
+'use strict';
+
+const AWS = require('aws-sdk'); // eslint-disable-line import/no-extraneous-dependencies
+
+const dynamoDb = new AWS.DynamoDB.DocumentClient();
+
+module.exports.update = (event, context, callback) => {
+ const timestamp = new Date().getTime();
+ const data = JSON.parse(event.body);
+
+ // validation
+ if (typeof data.text !== 'string' || typeof data.checked !== 'boolean') {
+ console.error('Validation Failed');
+ callback(null, {
+ statusCode: 400,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t update the todo item.',
+ });
+ return;
+ }
+
+ const params = {
+ TableName: process.env.DYNAMODB_TABLE,
+ Key: {
+ id: event.pathParameters.id,
+ },
+ ExpressionAttributeNames: {
+ '#todo_text': 'text',
+ },
+ ExpressionAttributeValues: {
+ ':text': data.text,
+ ':checked': data.checked,
+ ':updatedAt': timestamp,
+ },
+ UpdateExpression: 'SET #todo_text = :text, checked = :checked, updatedAt = :updatedAt',
+ ReturnValues: 'ALL_NEW',
+ };
+
+ // update the todo in the database
+ dynamoDb.update(params, (error, result) => {
+ // handle potential errors
+ if (error) {
+ console.error(error);
+ callback(null, {
+ statusCode: error.statusCode || 501,
+ headers: { 'Content-Type': 'text/plain' },
+ body: 'Couldn\'t fetch the todo item.',
+ });
+ return;
+ }
+
+ // create a response
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify(result.Attributes),
+ };
+ callback(null, response);
+ });
+};
\ No newline at end of file
diff --git a/aws-node-http-api-typescript-dynamodb/tsconfig.json b/aws-node-http-api-typescript-dynamodb/tsconfig.json
new file mode 100644
index 000000000..b61445848
--- /dev/null
+++ b/aws-node-http-api-typescript-dynamodb/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "compilerOptions": {
+ "target": "es6",
+ "module": "commonjs"
+ },
+ "exclude": [
+ "node_modules"
+ ],
+ "types": [
+ "node",
+ "aws-sdk"
+ ]
+}
diff --git a/aws-node-http-api-typescript-dynamodb/tslint.json b/aws-node-http-api-typescript-dynamodb/tslint.json
new file mode 100644
index 000000000..888779856
--- /dev/null
+++ b/aws-node-http-api-typescript-dynamodb/tslint.json
@@ -0,0 +1,3 @@
+{
+ "extends": "tslint-config-standard"
+}
diff --git a/aws-node-http-api-typescript/.gitignore b/aws-node-http-api-typescript/.gitignore
new file mode 100644
index 000000000..2b48c8bd5
--- /dev/null
+++ b/aws-node-http-api-typescript/.gitignore
@@ -0,0 +1,6 @@
+# package directories
+node_modules
+jspm_packages
+
+# Serverless directories
+.serverless
\ No newline at end of file
diff --git a/aws-node-http-api-typescript/README.md b/aws-node-http-api-typescript/README.md
new file mode 100644
index 000000000..b869893f1
--- /dev/null
+++ b/aws-node-http-api-typescript/README.md
@@ -0,0 +1,45 @@
+
+
+# Serverless Framework Node with Typescript HTTP API on AWS
+
+This template demonstrates how to make a simple HTTP API with Node.js and Typescript running on AWS Lambda and API Gateway using the Serverless Framework v1.
+
+This template does not include any kind of persistence (database). For more advanced examples, check out the [serverless/examples repository](https://github.com/serverless/examples) which includes Typescript, Mongo, DynamoDB and other examples.
+
+## Setup
+
+Run this command to initialize a new project in a new working directory.
+
+```
+npm install
+```
+
+## Usage
+
+**Deploy**
+
+```
+$ serverless deploy
+```
+
+**Invoke the function locally.**
+
+```
+serverless invoke local --function hello
+```
+
+**Invoke the function**
+
+```
+curl https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/
+```
diff --git a/aws-node-http-api-typescript/handler.ts b/aws-node-http-api-typescript/handler.ts
new file mode 100644
index 000000000..0d2f0e05a
--- /dev/null
+++ b/aws-node-http-api-typescript/handler.ts
@@ -0,0 +1,19 @@
+import { Handler } from 'aws-lambda';
+
+export const hello: Handler = (event: any) => {
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify(
+ {
+ message: 'Go Serverless v1.0! Your function executed successfully!',
+ input: event,
+ },
+ null,
+ 2
+ ),
+ };
+
+ return new Promise((resolve) => {
+ resolve(response)
+ })
+}
\ No newline at end of file
diff --git a/aws-node-http-api-typescript/package.json b/aws-node-http-api-typescript/package.json
new file mode 100644
index 000000000..2e859125a
--- /dev/null
+++ b/aws-node-http-api-typescript/package.json
@@ -0,0 +1,13 @@
+{
+ "name": "serverless-http-api-typescript",
+ "description": "",
+ "version": "0.1.0",
+ "dependencies": {},
+ "devDependencies": {
+ "@types/aws-lambda": "^8.10.61",
+ "serverless": "^1.78.1",
+ "serverless-offline": "^6.5.0",
+ "serverless-plugin-typescript": "^1.1.9",
+ "typescript": "^3.9.7"
+ }
+}
diff --git a/aws-node-http-api-typescript/serverless.template.yml b/aws-node-http-api-typescript/serverless.template.yml
new file mode 100644
index 000000000..66f1a43e8
--- /dev/null
+++ b/aws-node-http-api-typescript/serverless.template.yml
@@ -0,0 +1,6 @@
+name: aws-node-http-api-typescript
+org: serverlessinc
+description: Deploys a Node HTTP API service with Serverless Framework and Typescript
+keywords: aws, serverless, faas, lambda, node, typescript
+repo: https://github.com/serverless/examples/aws-node-http-api-typescript
+license: MIT
diff --git a/aws-node-http-api-typescript/serverless.yml b/aws-node-http-api-typescript/serverless.yml
new file mode 100644
index 000000000..8be87264f
--- /dev/null
+++ b/aws-node-http-api-typescript/serverless.yml
@@ -0,0 +1,18 @@
+service: serverless-http-api-typescript
+frameworkVersion: '2'
+
+provider:
+ name: aws
+ runtime: nodejs12.x
+ lambdaHashingVersion: '20201221'
+
+functions:
+ hello:
+ handler: handler.hello
+ events:
+ - httpApi:
+ path: /
+ method: get
+
+plugins:
+ - serverless-plugin-typescript
diff --git a/aws-node-http-api/.gitignore b/aws-node-http-api/.gitignore
new file mode 100644
index 000000000..2b48c8bd5
--- /dev/null
+++ b/aws-node-http-api/.gitignore
@@ -0,0 +1,6 @@
+# package directories
+node_modules
+jspm_packages
+
+# Serverless directories
+.serverless
\ No newline at end of file
diff --git a/aws-node-http-api/README.md b/aws-node-http-api/README.md
new file mode 100644
index 000000000..23c71d6dc
--- /dev/null
+++ b/aws-node-http-api/README.md
@@ -0,0 +1,113 @@
+
+
+# Serverless Framework Node HTTP API on AWS
+
+This template demonstrates how to make a simple HTTP API with Node.js running on AWS Lambda and API Gateway using the Serverless Framework.
+
+This template does not include any kind of persistence (database). For more advanced examples, check out the [serverless/examples repository](https://github.com/serverless/examples/) which includes Typescript, Mongo, DynamoDB and other examples.
+
+## Usage
+
+### Deployment
+
+```
+$ serverless deploy
+```
+
+After deploying, you should see output similar to:
+
+```bash
+Serverless: Packaging service...
+Serverless: Excluding development dependencies...
+Serverless: Creating Stack...
+Serverless: Checking Stack create progress...
+........
+Serverless: Stack create finished...
+Serverless: Uploading CloudFormation file to S3...
+Serverless: Uploading artifacts...
+Serverless: Uploading service aws-node-http-api.zip file to S3 (711.23 KB)...
+Serverless: Validating template...
+Serverless: Updating Stack...
+Serverless: Checking Stack update progress...
+.................................
+Serverless: Stack update finished...
+Service Information
+service: serverless-http-api
+stage: dev
+region: us-east-1
+stack: serverless-http-api-dev
+resources: 12
+api keys:
+ None
+endpoints:
+ ANY - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/
+functions:
+ api: serverless-http-api-dev-hello
+layers:
+ None
+```
+
+_Note_: In current form, after deployment, your API is public and can be invoked by anyone. For production deployments, you might want to configure an authorizer. For details on how to do that, refer to [http event docs](https://www.serverless.com/framework/docs/providers/aws/events/apigateway/).
+
+### Invocation
+
+After successful deployment, you can call the created application via HTTP:
+
+```bash
+curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/
+```
+
+Which should result in response similar to the following (removed `input` content for brevity):
+
+```json
+{
+ "message": "Go Serverless v2.0! Your function executed successfully!",
+ "input": {
+ ...
+ }
+}
+```
+
+### Local development
+
+You can invoke your function locally by using the following command:
+
+```bash
+serverless invoke local --function hello
+```
+
+Which should result in response similar to the following:
+
+```
+{
+ "statusCode": 200,
+ "body": "{\n \"message\": \"Go Serverless v2.0! Your function executed successfully!\",\n \"input\": \"\"\n}"
+}
+```
+
+
+Alternatively, it is also possible to emulate API Gateway and Lambda locally by using `serverless-offline` plugin. In order to do that, execute the following command:
+
+```bash
+serverless plugin install -n serverless-offline
+```
+
+It will add the `serverless-offline` plugin to `devDependencies` in `package.json` file as well as will add it to `plugins` in `serverless.yml`.
+
+After installation, you can start local emulation with:
+
+```
+serverless offline
+```
+
+To learn more about the capabilities of `serverless-offline`, please refer to its [GitHub repository](https://github.com/dherault/serverless-offline).
diff --git a/aws-node-http-api/handler.js b/aws-node-http-api/handler.js
new file mode 100644
index 000000000..69bddf913
--- /dev/null
+++ b/aws-node-http-api/handler.js
@@ -0,0 +1,15 @@
+"use strict";
+
+module.exports.hello = async (event) => {
+ return {
+ statusCode: 200,
+ body: JSON.stringify(
+ {
+ message: "Go Serverless v2.0! Your function executed successfully!",
+ input: event,
+ },
+ null,
+ 2
+ ),
+ };
+};
diff --git a/aws-node-http-api/serverless.template.yml b/aws-node-http-api/serverless.template.yml
new file mode 100644
index 000000000..e6dd8879c
--- /dev/null
+++ b/aws-node-http-api/serverless.template.yml
@@ -0,0 +1,6 @@
+name: aws-node-http-api
+org: serverlessinc
+description: Deploys a Node HTTP API service with traditional Serverless Framework
+keywords: aws, serverless, faas, lambda, node
+repo: https://github.com/serverless/examples/aws-node-http-api
+license: MIT
diff --git a/aws-node-http-api/serverless.yml b/aws-node-http-api/serverless.yml
new file mode 100644
index 000000000..8865fc18a
--- /dev/null
+++ b/aws-node-http-api/serverless.yml
@@ -0,0 +1,15 @@
+service: serverless-http-api
+frameworkVersion: '2 || 3'
+
+provider:
+ name: aws
+ runtime: nodejs12.x
+ lambdaHashingVersion: '20201221'
+
+functions:
+ hello:
+ handler: handler.hello
+ events:
+ - httpApi:
+ path: /
+ method: get
diff --git a/aws-node-iot-event/README.md b/aws-node-iot-event/README.md
index 309455369..f36ec51cf 100644
--- a/aws-node-iot-event/README.md
+++ b/aws-node-iot-event/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/rupakg'
authorName: 'Rupak Ganguly'
authorAvatar: 'https://avatars0.githubusercontent.com/u/8188?v=4&s=140'
diff --git a/aws-node-mongodb-atlas/README.md b/aws-node-mongodb-atlas/README.md
index 5819bd697..6516fe85f 100644
--- a/aws-node-mongodb-atlas/README.md
+++ b/aws-node-mongodb-atlas/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/welkie'
authorName: 'Matt Welke'
authorAvatar: 'https://avatars0.githubusercontent.com/u/7719209'
diff --git a/aws-node-oauth-dropbox-api/README.md b/aws-node-oauth-dropbox-api/README.md
index 11f8c4484..316318ff8 100644
--- a/aws-node-oauth-dropbox-api/README.md
+++ b/aws-node-oauth-dropbox-api/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/serverless'
authorName: Jay Deshmukh
authorAvatar: 'https://avatars0.githubusercontent.com/u/38460988?v=4&s=140'
@@ -47,4 +48,4 @@ P.S :- add your access token in Authorization header after Bearer eg :- [Bearer
- Follow the same procedure for deploying it on AWS just make the necessary changes in the following files
- `config/stage.yml`
- `config/stage_test.yml`
- - `test/test.js (link to stage_test.yml)`
\ No newline at end of file
+ - `test/test.js (link to stage_test.yml)`
diff --git a/aws-node-puppeteer/README.md b/aws-node-puppeteer/README.md
index 21b39bea6..74df2039a 100644
--- a/aws-node-puppeteer/README.md
+++ b/aws-node-puppeteer/README.md
@@ -4,6 +4,7 @@ description: 'This example shows you how to run Puppeteer on AWS Lambda'
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/emaildano'
authorName: 'Daniel Olson'
authorAvatar: 'https://avatars3.githubusercontent.com/u/1872327?v=4&s=140'
diff --git a/aws-node-recursive-function/README.md b/aws-node-recursive-function/README.md
index fad1f63bd..630cfaa3f 100644
--- a/aws-node-recursive-function/README.md
+++ b/aws-node-recursive-function/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/rupakg'
authorName: 'Rupak Ganguly'
authorAvatar: 'https://avatars0.githubusercontent.com/u/8188?v=4&s=140'
diff --git a/aws-node-recursive-function/serverless.yml b/aws-node-recursive-function/serverless.yml
index 1a39d9e90..d5de4d4fc 100644
--- a/aws-node-recursive-function/serverless.yml
+++ b/aws-node-recursive-function/serverless.yml
@@ -7,12 +7,14 @@ custom:
provider:
name: aws
runtime: nodejs12.x
-# iamRoleStatements:
-# - Effect: "Allow"
-# Action:
-# - "lambda:InvokeFunction"
-# Resource: ${self:custom.functionARN}
+# iam:
+# role:
+# statements:
+# - Effect: "Allow"
+# Action:
+# - "lambda:InvokeFunction"
+# Resource: ${self:custom.functionARN}
functions:
recursiveExample:
- handler: handler.recursiveLambda
\ No newline at end of file
+ handler: handler.recursiveLambda
diff --git a/aws-node-rekognition-analysis-s3-image/README.md b/aws-node-rekognition-analysis-s3-image/README.md
index 9c5392bf2..65be53d2e 100644
--- a/aws-node-rekognition-analysis-s3-image/README.md
+++ b/aws-node-rekognition-analysis-s3-image/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/ScottBrenner'
authorName: 'Scott Brenner'
authorAvatar: 'https://avatars2.githubusercontent.com/u/416477?v=4&s=140'
diff --git a/aws-node-rekognition-analysis-s3-image/serverless.yml b/aws-node-rekognition-analysis-s3-image/serverless.yml
index 2e1712a13..37598200a 100644
--- a/aws-node-rekognition-analysis-s3-image/serverless.yml
+++ b/aws-node-rekognition-analysis-s3-image/serverless.yml
@@ -9,16 +9,17 @@ provider:
timeout: 10
stage: dev
region: us-east-1
-
- iamRoleStatements:
- - Effect: Allow
- Action:
- - s3:*
- Resource: "*"
- - Effect: "Allow"
- Action:
- - "rekognition:*"
- Resource: "*"
+ iam:
+ role:
+ statements:
+ - Effect: Allow
+ Action:
+ - s3:*
+ Resource: "*"
+ - Effect: "Allow"
+ Action:
+ - "rekognition:*"
+ Resource: "*"
functions:
imageAnalysis:
diff --git a/aws-node-rest-api-mongodb/README.md b/aws-node-rest-api-mongodb/README.md
index d62e6b439..28f88d23e 100644
--- a/aws-node-rest-api-mongodb/README.md
+++ b/aws-node-rest-api-mongodb/README.md
@@ -5,6 +5,7 @@ layout: Doc
framework: v1
platform: AWS
language: nodeJS
+priority: 10
authorLink: 'https://github.com/lucianopf'
authorName: 'Luciano Pellacani Franca'
authorAvatar: 'https://avatars2.githubusercontent.com/u/8251208?v=4&s=140'
diff --git a/aws-node-rest-api-typescript-simple/.gitignore b/aws-node-rest-api-typescript-simple/.gitignore
new file mode 100644
index 000000000..2b48c8bd5
--- /dev/null
+++ b/aws-node-rest-api-typescript-simple/.gitignore
@@ -0,0 +1,6 @@
+# package directories
+node_modules
+jspm_packages
+
+# Serverless directories
+.serverless
\ No newline at end of file
diff --git a/aws-node-rest-api-typescript-simple/README.md b/aws-node-rest-api-typescript-simple/README.md
new file mode 100644
index 000000000..b1867341e
--- /dev/null
+++ b/aws-node-rest-api-typescript-simple/README.md
@@ -0,0 +1,49 @@
+
+
+# Serverless Framework Node with Typescript REST API on AWS
+
+This template demonstrates how to make a simple REST API with Node.js and Typescript running on AWS Lambda and API Gateway using the Serverless Framework v1.
+
+This template does not include any kind of persistence (database). For a more advanced example check out the [aws-node-rest-api-typescript example](https://github.com/serverless/examples/tree/master/aws-node-rest-api-typescript) which has must RESTful resources and persistence using MongoDB.
+
+## Setup
+
+Run this command to initialize a new project in a new working directory.
+
+`sls init aws-node-rest-api-typescript`
+
+## Usage
+
+**Deploy**
+
+This example is made to work with the Serverless Framework dashboard which includes advanced features like CI/CD, monitoring, metrics, etc.
+
+```
+$ serverless login
+$ serverless deploy
+```
+
+To deploy without the dashboard you will need to remove `org` and `app` fields from the `serverless.yml`, and you won’t have to run `sls login` before deploying.
+
+**Invoke the function locally.**
+
+```
+serverless invoke local --function hello
+```
+
+**Invoke the function**
+
+```
+curl https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/
+```
diff --git a/aws-node-rest-api-typescript-simple/handler.ts b/aws-node-rest-api-typescript-simple/handler.ts
new file mode 100644
index 000000000..0d2f0e05a
--- /dev/null
+++ b/aws-node-rest-api-typescript-simple/handler.ts
@@ -0,0 +1,19 @@
+import { Handler } from 'aws-lambda';
+
+export const hello: Handler = (event: any) => {
+ const response = {
+ statusCode: 200,
+ body: JSON.stringify(
+ {
+ message: 'Go Serverless v1.0! Your function executed successfully!',
+ input: event,
+ },
+ null,
+ 2
+ ),
+ };
+
+ return new Promise((resolve) => {
+ resolve(response)
+ })
+}
\ No newline at end of file
diff --git a/aws-node-rest-api-typescript-simple/package.json b/aws-node-rest-api-typescript-simple/package.json
new file mode 100644
index 000000000..0fdd6410d
--- /dev/null
+++ b/aws-node-rest-api-typescript-simple/package.json
@@ -0,0 +1,13 @@
+{
+ "name": "aws-node-rest-api-typescript",
+ "description": "",
+ "version": "0.1.0",
+ "dependencies": {},
+ "devDependencies": {
+ "@types/aws-lambda": "^8.10.61",
+ "serverless": "^1.78.1",
+ "serverless-offline": "^6.5.0",
+ "serverless-plugin-typescript": "^1.1.9",
+ "typescript": "^3.9.7"
+ }
+}
diff --git a/aws-node-rest-api-typescript-simple/serverless.yml b/aws-node-rest-api-typescript-simple/serverless.yml
new file mode 100644
index 000000000..369ab0ad1
--- /dev/null
+++ b/aws-node-rest-api-typescript-simple/serverless.yml
@@ -0,0 +1,18 @@
+org: serverlessinc
+app: aws-node-rest-api-typescript
+service: aws-node-rest-api-typescript
+
+provider:
+ name: aws
+ runtime: nodejs12.x
+
+functions:
+ hello:
+ handler: handler.hello
+ events:
+ - http:
+ path: /
+ method: get
+
+plugins:
+ - serverless-plugin-typescript
diff --git a/aws-node-rest-api-typescript/.editorconfig b/aws-node-rest-api-typescript/.editorconfig
new file mode 100644
index 000000000..481327c74
--- /dev/null
+++ b/aws-node-rest-api-typescript/.editorconfig
@@ -0,0 +1,4 @@
+root = true
+[*]
+indent_style = space
+indent_size = 2
\ No newline at end of file
diff --git a/aws-node-rest-api-typescript/.gitignore b/aws-node-rest-api-typescript/.gitignore
new file mode 100644
index 000000000..05a28be35
--- /dev/null
+++ b/aws-node-rest-api-typescript/.gitignore
@@ -0,0 +1,18 @@
+# package directories
+node_modules
+jspm_packages
+
+# Serverless directories
+.serverless
+
+.build
+
+.nyc_output
+
+coverage
+
+package-lock.json
+
+out-logger.json
+
+.DS_Store
\ No newline at end of file
diff --git a/aws-node-rest-api-typescript/.nycrc.json b/aws-node-rest-api-typescript/.nycrc.json
new file mode 100644
index 000000000..f59b39ecb
--- /dev/null
+++ b/aws-node-rest-api-typescript/.nycrc.json
@@ -0,0 +1,11 @@
+{
+ "all": true,
+ "report-dir": "./coverage",
+ "extension": [".ts"],
+ "exclude": [
+ "app/model/dto/**.ts",
+ "app/model/vo/**.ts",
+ "coverage",
+ "tests"
+ ]
+}
\ No newline at end of file
diff --git a/aws-node-rest-api-typescript/README.md b/aws-node-rest-api-typescript/README.md
new file mode 100644
index 000000000..ce180fa35
--- /dev/null
+++ b/aws-node-rest-api-typescript/README.md
@@ -0,0 +1,113 @@
+
+# Serverless Nodejs Rest API with TypeScript And MongoDB Atlas
+
+This is simple REST API example for AWS Lambda By Serverless framwork with TypeScript and MongoDB Atlas.
+
+## Use Cases
+
+* REST API with typescript
+* MongoDB Atlas data storage
+* Multi-environment management under Serverless
+* Mocha unit tests and lambda-tester interface test
+* AWS lambda function log view
+
+## Invoke the function locally
+
+```bash
+serverless invoke local --function find
+```
+
+Which should result in:
+
+```bash
+Serverless: Compiling with Typescript...
+Serverless: Using local tsconfig.json
+Serverless: Typescript compiled.
+
+{
+ "statusCode": 200,
+ "body": "{\"code\":0,\"message\":\"success\",\"data\":[{\"_id\":\"5dff21f71c9d440000a30dad\",\"createdAt\":\"2020-05-16T09:27:51.219Z\"},{\"_id\":\"5dff22ba1c9d440000a30dae\",\"createdAt\":\"2020-05-16T09:27:51.220Z\"}]}"
+}
+```
+
+## Deploy
+
+### To Test It Locally
+
+* Run ```npm install``` to install all the necessary dependencies.
+* Run ```npm run local``` use serverless offline to test locally.
+
+### Deploy on AWS, simply run:
+
+```
+$ npm run deploy
+
+# or
+
+$ serverless deploy
+```
+
+The expected result should be similar to:
+
+```
+Serverless: Compiling with Typescript...
+Serverless: Using local tsconfig.json
+Serverless: Typescript compiled.
+Serverless: Packaging service...
+Serverless: Excluding development dependencies...
+Serverless: Uploading CloudFormation file to S3...
+Serverless: Uploading artifacts...
+Serverless: Uploading service aws-node-rest-api-typescript.zip file to S3 (1.86 MB)...
+Serverless: Validating template...
+Serverless: Updating Stack...
+Serverless: Checking Stack update progress...
+......................................
+Serverless: Stack update finished...
+Service Information
+service: aws-node-rest-api-typescript
+stage: dev
+region: us-east-1
+stack: aws-node-rest-api-typescript-dev
+resources: 32
+api keys:
+ None
+endpoints:
+ POST - https://xxxxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/books
+ PUT - https://xxxxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/books/{id}
+ GET - https://xxxxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/books
+ GET - https://xxxxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/books/{id}
+ DELETE - https://xxxxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/books/{id}
+functions:
+ create: aws-node-rest-api-typescript-dev-create
+ update: aws-node-rest-api-typescript-dev-update
+ find: aws-node-rest-api-typescript-dev-find
+ findOne: aws-node-rest-api-typescript-dev-findOne
+ deleteOne: aws-node-rest-api-typescript-dev-deleteOne
+layers:
+ None
+Serverless: Removing old service artifacts from S3...
+Serverless: Run the "serverless" command to setup monitoring, troubleshooting and testing.
+```
+
+## Usage
+
+send an HTTP request directly to the endpoint using a tool like curl
+
+```
+curl https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/books
+```
+
+## Scaling
+
+By default, AWS Lambda limits the total concurrent executions across all functions within a given region to 100. The default limit is a safety limit that protects you from costs due to potential runaway or recursive functions during initial development and testing. To increase this limit above the default, follow the steps in [To request a limit increase for concurrent executions](http://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html#increase-concurrent-executions-limit).
diff --git a/aws-node-rest-api-typescript/app/controller/books.ts b/aws-node-rest-api-typescript/app/controller/books.ts
new file mode 100644
index 000000000..7d31e8239
--- /dev/null
+++ b/aws-node-rest-api-typescript/app/controller/books.ts
@@ -0,0 +1,109 @@
+import { Context } from 'aws-lambda';
+import { Model } from 'mongoose';
+import { MessageUtil } from '../utils/message';
+import { BooksService } from '../service/books';
+import { CreateBookDTO } from '../model/dto/createBookDTO';
+
+export class BooksController extends BooksService {
+ constructor (books: Model) {
+ super(books);
+ }
+
+ /**
+ * Create book
+ * @param {*} event
+ */
+ async create (event: any, context?: Context) {
+ console.log('functionName', context.functionName);
+ const params: CreateBookDTO = JSON.parse(event.body);
+
+ try {
+ const result = await this.createBook({
+ name: params.name,
+ id: params.id,
+ });
+
+ return MessageUtil.success(result);
+ } catch (err) {
+ console.error(err);
+
+ return MessageUtil.error(err.code, err.message);
+ }
+ }
+
+ /**
+ * Update a book by id
+ * @param event
+ */
+ async update (event: any) {
+ const id: number = Number(event.pathParameters.id);
+ const body: object = JSON.parse(event.body);
+
+ try {
+ const result = await this.updateBooks(id, body);
+ return MessageUtil.success(result);
+ } catch (err) {
+ console.error(err);
+
+ return MessageUtil.error(err.code, err.message);
+ }
+ }
+
+ /**
+ * Find book list
+ */
+ async find () {
+ try {
+ const result = await this.findBooks();
+
+ return MessageUtil.success(result);
+ } catch (err) {
+ console.error(err);
+
+ return MessageUtil.error(err.code, err.message);
+ }
+ }
+
+ /**
+ * Query book by id
+ * @param event
+ */
+ async findOne (event: any, context: Context) {
+ // The amount of memory allocated for the function
+ console.log('memoryLimitInMB: ', context.memoryLimitInMB);
+
+ const id: number = Number(event.pathParameters.id);
+
+ try {
+ const result = await this.findOneBookById(id);
+
+ return MessageUtil.success(result);
+ } catch (err) {
+ console.error(err);
+
+ return MessageUtil.error(err.code, err.message);
+ }
+ }
+
+ /**
+ * Delete book by id
+ * @param event
+ */
+ async deleteOne (event: any) {
+ const id: number = event.pathParameters.id;
+
+ try {
+ const result = await this.deleteOneBookById(id);
+
+ if (result.deletedCount === 0) {
+ return MessageUtil.error(1010, 'The data was not found! May have been deleted!');
+ }
+
+ return MessageUtil.success(result);
+ } catch (err) {
+ console.error(err);
+
+ return MessageUtil.error(err.code, err.message);
+ }
+ }
+}
diff --git a/aws-node-rest-api-typescript/app/handler.ts b/aws-node-rest-api-typescript/app/handler.ts
new file mode 100644
index 000000000..37abef8be
--- /dev/null
+++ b/aws-node-rest-api-typescript/app/handler.ts
@@ -0,0 +1,26 @@
+
+import { Handler, Context } from 'aws-lambda';
+import dotenv from 'dotenv';
+import path from 'path';
+const dotenvPath = path.join(__dirname, '../', `config/.env.${process.env.NODE_ENV}`);
+dotenv.config({
+ path: dotenvPath,
+});
+
+import { books } from './model';
+import { BooksController } from './controller/books';
+const booksController = new BooksController(books);
+
+export const create: Handler = (event: any, context: Context) => {
+ return booksController.create(event, context);
+};
+
+export const update: Handler = (event: any) => booksController.update(event);
+
+export const find: Handler = () => booksController.find();
+
+export const findOne: Handler = (event: any, context: Context) => {
+ return booksController.findOne(event, context);
+};
+
+export const deleteOne: Handler = (event: any) => booksController.deleteOne(event);
diff --git a/aws-node-rest-api-typescript/app/model/books.ts b/aws-node-rest-api-typescript/app/model/books.ts
new file mode 100644
index 000000000..69daa8a5b
--- /dev/null
+++ b/aws-node-rest-api-typescript/app/model/books.ts
@@ -0,0 +1,20 @@
+import mongoose from 'mongoose';
+
+export type BooksDocument = mongoose.Document & {
+ name: string,
+ id: number,
+ description: string,
+ createdAt: Date,
+};
+
+const booksSchema = new mongoose.Schema({
+ name: String,
+ id: { type: Number, index: true, unique: true },
+ description: String,
+ createdAt: { type: Date, default: Date.now },
+});
+
+// Note: OverwriteModelError: Cannot overwrite `Books` model once compiled. error
+export const books = (mongoose.models.books ||
+mongoose.model('books', booksSchema, process.env.DB_BOOKS_COLLECTION)
+);
\ No newline at end of file
diff --git a/aws-node-rest-api-typescript/app/model/dto/createBookDTO.ts b/aws-node-rest-api-typescript/app/model/dto/createBookDTO.ts
new file mode 100644
index 000000000..0f1d4dbcb
--- /dev/null
+++ b/aws-node-rest-api-typescript/app/model/dto/createBookDTO.ts
@@ -0,0 +1,5 @@
+export class CreateBookDTO {
+ name: string;
+ id: number;
+ description?: string;
+}
diff --git a/aws-node-rest-api-typescript/app/model/index.ts b/aws-node-rest-api-typescript/app/model/index.ts
new file mode 100644
index 000000000..c3a81e94c
--- /dev/null
+++ b/aws-node-rest-api-typescript/app/model/index.ts
@@ -0,0 +1,2 @@
+export * from './mongoose-db';
+export * from './books';
diff --git a/aws-node-rest-api-typescript/app/model/mongoose-db.ts b/aws-node-rest-api-typescript/app/model/mongoose-db.ts
new file mode 100644
index 000000000..5773860d9
--- /dev/null
+++ b/aws-node-rest-api-typescript/app/model/mongoose-db.ts
@@ -0,0 +1,7 @@
+import mongoose from 'mongoose';
+
+export default mongoose.connect(process.env.DB_URL, {
+ dbName: process.env.DB_NAME,
+ useUnifiedTopology: true,
+ useNewUrlParser: true,
+});
diff --git a/aws-node-rest-api-typescript/app/model/vo/responseVo.ts b/aws-node-rest-api-typescript/app/model/vo/responseVo.ts
new file mode 100644
index 000000000..37517e2bc
--- /dev/null
+++ b/aws-node-rest-api-typescript/app/model/vo/responseVo.ts
@@ -0,0 +1,10 @@
+export class ResponseBodyVO {
+ code: number;
+ message: string;
+ data?: object;
+}
+
+export class ResponseVO {
+ statusCode: number;
+ body: string;
+}
diff --git a/aws-node-rest-api-typescript/app/service/books.ts b/aws-node-rest-api-typescript/app/service/books.ts
new file mode 100644
index 000000000..a6c09d6ef
--- /dev/null
+++ b/aws-node-rest-api-typescript/app/service/books.ts
@@ -0,0 +1,64 @@
+import { Model } from 'mongoose';
+import { CreateBookDTO } from '../model/dto/createBookDTO';
+
+export class BooksService {
+ private books: Model;
+ constructor(books: Model) {
+ this.books = books;
+ }
+
+ /**
+ * Create book
+ * @param params
+ */
+ protected async createBook (params: CreateBookDTO): Promise