├── .editorconfig ├── .eslintignore ├── .eslintrc.json ├── .github └── pull_request_template.md ├── .gitignore ├── .travis.yml ├── LICENSE.txt ├── Makefile ├── README.md ├── aws-dotnet-rest-api-with-dynamodb ├── .gitignore ├── DotNetServerless.sln ├── README.MD ├── src │ ├── DotNetServerless.Application │ │ ├── DotNetServerless.Application.csproj │ │ ├── Entities │ │ │ └── Item.cs │ │ ├── Handlers │ │ │ ├── CreateItemHandler.cs │ │ │ ├── GetItemHandler.cs │ │ │ └── UpdateItemHandler.cs │ │ ├── Infrastructure │ │ │ ├── AWSClientFactory.cs │ │ │ ├── Configs │ │ │ │ ├── AwsBasicConfiguration.cs │ │ │ │ └── DynamoDbConfiguration.cs │ │ │ └── Repositories │ │ │ │ ├── IItemRepository.cs │ │ │ │ └── ItemDynamoRepository.cs │ │ ├── Requests │ │ │ ├── CreateItemRequest.cs │ │ │ ├── GetItemRequest.cs │ │ │ └── UpdateItemRequest.cs │ │ └── Responses │ │ │ └── ItemResponse.cs │ └── DotNetServerless.Lambda │ │ ├── DotNetServerless.Lambda.csproj │ │ ├── Extensions │ │ └── ServicesExtensions.cs │ │ ├── Functions │ │ ├── CreateItemFunction.cs │ │ ├── GetItemFunction.cs │ │ └── UpdateItemFunction.cs │ │ ├── Program.cs │ │ ├── Startup.cs │ │ ├── package-lock.json │ │ ├── package.json │ │ └── serverless.yml └── tests │ └── DotNetServerless.Tests │ ├── DotNetServerless.Tests.csproj │ └── Functions │ ├── CreateItemFunctionTests.cs │ ├── GetItemFunctionTests.cs │ └── UpdateItemFunctionTests.cs ├── aws-ffmpeg-layer ├── .gitignore ├── README.md ├── build.sh ├── handler.js ├── package.json └── serverless.yml ├── aws-golang-auth-examples ├── .gitignore ├── Makefile ├── README.md ├── functions │ ├── auth │ │ ├── auth_suite_test.go │ │ ├── main.go │ │ └── main_test.go │ ├── auth2 │ │ ├── auth_suite_test.go │ │ ├── main.go │ │ └── main_test.go │ ├── hello-world │ │ ├── hello_world_suite_test.go │ │ ├── main.go │ │ └── main_test.go │ └── hello-world2 │ │ ├── hello_world_suite_test.go │ │ ├── main.go │ │ └── main_test.go ├── go.mod ├── go.sum ├── package.json └── serverless.yml ├── aws-golang-dynamo-stream-to-elasticsearch ├── Gopkg.toml ├── Makefile ├── README.md ├── cmd │ ├── aws-golang-dynamo-stream-to-elasticsearch │ │ └── main.go │ └── seed-dynamo │ │ └── main.go ├── docs │ ├── kibana.png │ └── query.png ├── dstream │ ├── details.go │ └── update.go ├── package.json └── serverless.yml ├── aws-golang-googlemap ├── Gopkg.lock ├── Gopkg.toml ├── Makefile ├── README.md ├── geomap │ └── geomap.go ├── getgeodetail │ └── main.go ├── getgeolocation │ └── main.go ├── getnearbylocation │ └── main.go ├── getsearchlocation │ └── main.go └── serverless.yml ├── aws-golang-http-get-post ├── Gopkg.lock ├── Gopkg.toml ├── Makefile ├── README.md ├── getFolder │ ├── getExample.go │ └── getQueryExample.go ├── package.json ├── postFolder │ └── postExample.go └── serverless.yml ├── aws-golang-simple-http-endpoint ├── Gopkg.toml ├── Makefile ├── README.md ├── hello │ └── main.go ├── package.json ├── serverless.yml └── world │ └── main.go ├── aws-golang-stream-kinesis-to-elasticsearch ├── Gopkg.lock ├── Gopkg.toml ├── Makefile ├── README.md ├── elastic │ └── elastic.go ├── main.go ├── package.json └── serverless.yml ├── aws-java-simple-http-endpoint ├── .gitignore ├── README.md ├── build.gradle ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── pom.xml ├── serverless.yml └── src │ └── main │ ├── java │ └── com │ │ └── serverless │ │ ├── ApiGatewayResponse.java │ │ ├── Handler.java │ │ └── Response.java │ └── resources │ └── log4j.properties ├── aws-multiple-runtime ├── README.md ├── api │ ├── .gitignore │ └── handler.js ├── serverless.yml └── web │ └── handler.py ├── aws-node-alexa-skill ├── .gitignore ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── aws-node-auth0-cognito-custom-authorizers-api ├── .gitignore ├── README.md ├── auth.js ├── handler.js ├── package.json └── serverless.yml ├── aws-node-auth0-custom-authorizers-api ├── .gitignore ├── README.md ├── frontend │ ├── app.css │ ├── app.js │ └── index.html ├── handler.js ├── package.json ├── public_key-example ├── secrets.example.json ├── serverless.yml └── yarn.lock ├── aws-node-dynamic-image-resizer ├── Dockerfile ├── README.md ├── config │ ├── .env.example │ ├── pull-secret.sh │ └── push-secret.sh ├── deploy.sh ├── docker-compose.yml ├── package.json ├── secrets │ ├── secrets.env │ └── secrets.json ├── serverless.yml ├── src │ ├── handlers │ │ └── resizer │ │ │ ├── index.js │ │ │ ├── resizeHandler.js │ │ │ └── s3Handler.js │ └── lib │ │ └── BaseHandler.js ├── webpack.config.js └── yarn.lock ├── aws-node-dynamodb-backup ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── aws-node-env-variables-encrypted-in-a-file ├── .gitignore ├── README.md ├── handler.js ├── package.json ├── secrets.dev.yml.encrypted ├── secrets.prod.yml.encrypted └── serverless.yml ├── aws-node-env-variables ├── .gitignore ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── aws-node-fetch-file-and-store-in-s3 ├── .gitignore ├── README.md ├── handler.js ├── package-lock.json ├── package.json └── serverless.yml ├── aws-node-fullstack ├── README.md ├── backend │ ├── .gitignore │ ├── index.js │ ├── package-lock.json │ ├── package.json │ ├── serverless.yml │ └── yarn.lock └── frontend │ ├── .gitignore │ ├── package-lock.json │ ├── package.json │ ├── public │ ├── favicon.ico │ ├── index.html │ └── manifest.json │ ├── src │ ├── DemoApp.css │ ├── DemoApp.js │ ├── images │ │ └── logo.png │ ├── index.css │ └── index.js │ └── yarn.lock ├── aws-node-function-compiled-with-babel ├── .gitignore ├── README.md ├── createResponse.js ├── event.json ├── handler.js ├── package.json └── serverless.yml ├── aws-node-github-check ├── .babelrc ├── .gitignore ├── README.md ├── handler.js ├── libs │ ├── github-service.js │ └── response-lib.js ├── package-lock.json ├── package.json ├── serverless.yaml └── webpack.config.js ├── aws-node-github-webhook-listener ├── .gitignore ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── aws-node-graphql-and-rds ├── README.md ├── handler.js ├── package-lock.json ├── package.json ├── resolver │ ├── Common │ │ ├── aurora.js │ │ ├── mysql.js │ │ └── postgresql.js │ ├── Mutation │ │ ├── aurora_createUser.js │ │ ├── mysql_createUser.js │ │ └── postgresql_createUser.js │ └── Query │ │ ├── aurora_getUser.js │ │ ├── mysql_getUser.js │ │ └── postgresql_getUser.js ├── resource │ ├── AuroraRDSCluster.yml │ ├── AuroraRDSClusterParameter.yml │ ├── AuroraRDSInstance.yml │ ├── AuroraRDSInstanceParameter.yml │ ├── LambdaRole.yml │ ├── MySqlRDSInstance.yml │ ├── PostgreSqlRDSInstance.yml │ ├── RoutePublic.yml │ ├── RouteTableAssociationSubnetA.yml │ ├── RouteTableAssociationSubnetB.yml │ ├── RouteTableAssociationSubnetC.yml │ ├── RouteTablePublic.yml │ ├── ServerlessInternetGateway.yml │ ├── ServerlessSecurityGroup.yml │ ├── ServerlessSubnetA.yml │ ├── ServerlessSubnetB.yml │ ├── ServerlessSubnetC.yml │ ├── ServerlessSubnetGroup.yml │ ├── ServerlessVPC.yml │ └── ServerlessVPCGA.yml ├── schema.gql ├── secrets.json └── serverless.yml ├── aws-node-graphql-api-with-dynamodb ├── .gitignore ├── README.md ├── handler.js ├── package-lock.json ├── package.json └── serverless.yml ├── aws-node-heroku-postgres ├── .gitignore ├── README.md ├── handler.js ├── index.js ├── package-lock.json ├── package.json └── serverless.yml ├── aws-node-iot-event ├── .gitignore ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── aws-node-mongodb-atlas ├── .gitignore ├── README.md ├── handler.js ├── index.js ├── package-lock.json ├── package.json └── serverless.yml ├── aws-node-oauth-dropbox-api ├── .gitignore ├── README.md ├── config │ ├── default.yml │ ├── default_test.yml │ ├── stage.yml │ └── stage_test.yml ├── dropbox │ └── handler.js ├── package-lock.json ├── package.json ├── serverless.yml └── test │ └── test.js ├── aws-node-puppeteer ├── .gitignore ├── README.md ├── chrome-script.js ├── handler.js ├── images │ └── aws_limits.png ├── package-lock.json ├── package.json ├── serverless.yml └── yarn.lock ├── aws-node-recursive-function ├── .gitignore ├── README.md ├── event.json ├── handler.js └── serverless.yml ├── aws-node-rekognition-analysis-s3-image ├── .gitignore ├── README.md ├── handler.js ├── lib │ └── imageAnalyser.js ├── package.json ├── post.json └── serverless.yml ├── aws-node-rest-api-mongodb ├── .gitignore ├── README.md ├── handler.js ├── model │ └── User.js ├── package.json └── serverless.yml ├── aws-node-rest-api-with-dynamodb-and-offline ├── .gitignore ├── README.md ├── offline │ └── migrations │ │ └── todos.json ├── package.json ├── serverless.yml └── todos │ ├── create.js │ ├── delete.js │ ├── dynamodb.js │ ├── get.js │ ├── list.js │ └── update.js ├── aws-node-rest-api-with-dynamodb ├── .gitignore ├── README.md ├── package.json ├── serverless.yml └── todos │ ├── create.js │ ├── delete.js │ ├── get.js │ ├── list.js │ └── update.js ├── aws-node-s3-file-replicator ├── .gitignore ├── README.md ├── handler.js ├── package-lock.json ├── package.json └── serverless.yml ├── aws-node-scheduled-cron ├── .gitignore ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── aws-node-scheduled-weather ├── .gitignore ├── README.md ├── handler.js ├── lib │ ├── email.js │ └── forecast.js ├── package.json └── serverless.yml ├── aws-node-serve-dynamic-html-via-http-endpoint ├── .gitignore ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── aws-node-serverless-gong ├── README.md ├── handler.js ├── node ├── package.json ├── serverless-examples@0.0.0 └── serverless.yml ├── aws-node-ses-receive-email-body ├── .gitignore ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── aws-node-ses-receive-email-header ├── .gitignore ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── aws-node-shared-gateway ├── README.md ├── ci-decomission.sh ├── ci-deploy.sh ├── gateway │ ├── .gitignore │ └── serverless.yml ├── package.json ├── products │ ├── .gitignore │ ├── handler.js │ └── serverless.yml ├── transactions │ ├── .gitignore │ ├── handler.js │ └── serverless.yml └── users │ ├── .gitignore │ ├── handler.js │ └── serverless.yml ├── aws-node-signed-uploads ├── .babelrc ├── .eslintrc ├── .gitignore ├── README.md ├── package.json ├── serverless.yml ├── src │ └── upload.js ├── webpack.config.js └── yarn.lock ├── aws-node-simple-http-endpoint ├── .gitignore ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── aws-node-simple-transcribe-s3 ├── .gitignore ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── aws-node-single-page-app-via-cloudfront ├── .gitignore ├── README.md ├── app │ ├── app.js │ └── index.html ├── package.json ├── serverless-single-page-app-plugin │ ├── index.js │ └── package.json └── serverless.yml ├── aws-node-stripe-integration ├── .gitignore ├── README.md ├── config │ └── default.yaml ├── handler.js ├── package.json └── serverless.yml ├── aws-node-telegram-echo-bot ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── aws-node-text-analysis-via-sns-post-processing ├── .gitignore ├── README.md ├── addNote.js ├── analyzeNote.js ├── config.js ├── package.json └── serverless.yml ├── aws-node-twilio-send-text-message ├── .gitignore ├── .npmignore ├── README.md ├── event.json ├── frontend │ ├── app.css │ └── index.html ├── handler.js ├── messenger.js ├── messenger.test.js ├── package.json └── serverless.yml ├── aws-node-twitter-joke-bot ├── README.md ├── handler.js ├── helpers │ ├── jokes.js │ └── twitter.js ├── package-lock.json ├── package.json └── serverless.yml ├── aws-node-typescript-nest ├── .gitignore ├── .prettierrc ├── README.md ├── bench.js ├── nest-cli.json ├── nodemon-debug.json ├── nodemon.json ├── package-lock.json ├── package.json ├── serverless.yml ├── src │ ├── app.controller.spec.ts │ ├── app.controller.ts │ ├── app.module.ts │ ├── app.service.ts │ └── main.ts ├── test │ ├── app.e2e-spec.ts │ └── jest-e2e.json ├── tsconfig.build.json ├── tsconfig.json ├── tsconfig.spec.json └── tslint.json ├── aws-node-typescript-rest-api-with-dynamodb ├── .gitignore ├── README.md ├── package.json ├── serverless.yml ├── todos │ └── create.ts ├── tsconfig.json └── tslint.json ├── aws-node-typescript-sqs-standard ├── .gitignore ├── README.md ├── handler.ts ├── package-lock.json ├── package.json ├── serverless.yml ├── sqs │ ├── receiver.ts │ └── sender.ts ├── tsconfig.json ├── tslint.json └── webpack.config.js ├── aws-node-upload-to-s3-and-postprocess ├── .gitignore ├── README.md ├── frontend │ └── index.template.html ├── generate-form.js ├── handler.js ├── package.json └── serverless.yml ├── aws-node-vue-nuxt-ssr ├── .gitignore ├── README.md ├── binaryMimeTypes.js ├── client │ ├── components │ │ └── navbar.vue │ ├── layouts │ │ └── default.vue │ └── pages │ │ ├── dogs │ │ ├── _breed.vue │ │ └── index.vue │ │ └── index.vue ├── index.js ├── nuxt.config.js ├── nuxt.js ├── package.json ├── secrets.json ├── serverless.yml └── yarn.lock ├── aws-node-websockets-authorizers ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── aws-python-alexa-skill ├── .gitignore ├── README.md ├── handler.py ├── package.json └── serverless.yml ├── aws-python-auth0-custom-authorizers-api ├── .gitignore ├── Makefile ├── README.md ├── frontend │ ├── app.css │ ├── app.js │ └── index.html ├── lambda_handlers.py ├── package.json ├── public_key-example ├── requirements.txt ├── secrets.example.json └── serverless.yml ├── aws-python-line-echo-bot ├── README.md ├── handler.py ├── package.json ├── requirements.txt ├── serverless.yml └── setup.cfg ├── aws-python-pynamodb-s3-sigurl ├── .gitignore ├── README.md ├── asset │ ├── __init__.py │ ├── asset_model.py │ ├── bucket.py │ ├── create.py │ ├── delete.py │ ├── get.py │ ├── list.py │ └── update.py ├── log_cfg.py ├── package-lock.json ├── package.json ├── requirements.txt └── serverless.yml ├── aws-python-rest-api-with-dynamodb ├── .gitignore ├── README.md ├── package.json ├── serverless.yml └── todos │ ├── __init__.py │ ├── create.py │ ├── decimalencoder.py │ ├── delete.py │ ├── get.py │ ├── list.py │ └── update.py ├── aws-python-rest-api-with-faunadb ├── .gitignore ├── README.md ├── package.json ├── requirements.txt ├── serverless.yml └── todos │ ├── __init__.py │ ├── create.py │ ├── delete.py │ ├── get.py │ ├── list.py │ ├── makeresult.py │ ├── schema.py │ └── update.py ├── aws-python-rest-api-with-pymongo ├── README.md ├── item │ ├── __init__.py │ ├── create.py │ ├── delete.py │ ├── get.py │ └── list.py ├── package.json ├── requirements.txt └── serverless.yml ├── aws-python-rest-api-with-pynamodb ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── requirements.txt ├── serverless.yml └── todos │ ├── __init__.py │ ├── create.py │ ├── delete.py │ ├── get.py │ ├── list.py │ ├── todo_model.py │ └── update.py ├── aws-python-scheduled-cron ├── .gitignore ├── README.md ├── handler.py ├── package.json └── serverless.yml ├── aws-python-simple-http-endpoint ├── .gitignore ├── README.md ├── handler.py ├── package.json └── serverless.yml ├── aws-python-telegram-bot ├── .gitignore ├── LICENSE ├── README.md ├── handler.py ├── package.json ├── requirements.txt └── serverless.yml ├── aws-ruby-line-bot ├── .gitignore ├── Gemfile ├── Gemfile.lock ├── README.md ├── handler.rb ├── package.json └── serverless.yml ├── aws-ruby-simple-http-endpoint ├── .gitignore ├── README.md ├── handler.rb ├── package.json └── serverless.yml ├── azure-node-line-bot ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── azure-node-simple-http-endpoint ├── .gitignore ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── azure-node-telegram-bot ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── check-if-readme-is-up-to-date.sh ├── community-examples.json ├── generate-readme.js ├── google-golang-simple-http-endpoint ├── .gcloudignore ├── README.md ├── hello.go ├── package.json └── serverless.yml ├── google-node-simple-http-endpoint ├── README.md ├── index.js ├── package.json └── serverless.yml ├── google-node-typescript-http-endpoint ├── README.md ├── package.json ├── serverless.yml ├── src │ └── App.ts └── tsconfig.json ├── google-python-simple-http-endpoint ├── README.md ├── main.py ├── package.json ├── requirements.txt └── serverless.yml ├── kubeless-python-simple-function ├── README.md ├── handler.py ├── package.json └── serverless.yml ├── kubeless-python-simple-scheduled-function ├── README.md ├── handler.py ├── package.json └── serverless.yml ├── openwhisk-go-simple ├── .gitignore ├── README.md ├── handler.go ├── package.json └── serverless.yml ├── openwhisk-node-and-docker-chaining-functions ├── .gitignore ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── openwhisk-node-chaining-functions ├── .gitignore ├── README.md ├── handler.js ├── package.json ├── serverless.yml └── utils.js ├── openwhisk-node-scheduled-cron ├── .gitignore ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── openwhisk-node-simple-http-endpoint ├── .gitignore ├── README.md ├── handler.js ├── package.json └── serverless.yml ├── openwhisk-node-simple ├── .gitignore ├── README.md ├── delay.js ├── hello_world.js ├── left_pad.js ├── package.json └── serverless.yml ├── openwhisk-php-simple ├── .gitignore ├── README.md ├── handler.php ├── package.json └── serverless.yml ├── openwhisk-python-scheduled-cron ├── .gitignore ├── README.md ├── handler.py ├── package.json └── serverless.yml ├── openwhisk-python-simple-http-endpoint ├── .gitignore ├── README.md ├── handler.py ├── package.json └── serverless.yml ├── openwhisk-python-simple ├── .gitignore ├── README.md ├── handler.py ├── package.json └── serverless.yml ├── openwhisk-ruby-simple ├── .gitignore ├── README.md ├── handler.rb ├── package.json └── serverless.yml ├── openwhisk-swift-precompiled-binaries ├── Package.swift ├── README.md ├── Sources │ ├── hello │ │ └── main.swift │ └── welcome │ │ └── main.swift ├── package.json └── serverless.yml ├── openwhisk-swift-scheduled-cron ├── .gitignore ├── README.md ├── handler.swift ├── package.json └── serverless.yml ├── openwhisk-swift-simple-http-endpoint ├── .gitignore ├── README.md ├── package.json ├── ping.swift └── serverless.yml ├── openwhisk-swift-simple ├── .gitignore ├── README.md ├── package.json ├── ping.swift └── serverless.yml ├── package-lock.json ├── package.json ├── twilio-node-forward-call ├── .gitignore ├── README.md ├── forward-call.js ├── package-lock.json ├── package.json └── serverless.yml ├── validate.js └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.{diff,md}] 17 | trim_trailing_whitespace = false 18 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": "airbnb-base", 4 | "env": { 5 | "node": true 6 | }, 7 | "rules": { 8 | "strict": "off", 9 | "no-console": "off", 10 | "import/no-unresolved": "off" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | *.log 3 | npm-debug.log 4 | pids 5 | *.pid 6 | *.seed 7 | dist 8 | lib-cov 9 | coverage 10 | .grunt 11 | .lock-wscript 12 | node_modules 13 | .idea 14 | .DS_Store 15 | .tmp 16 | .env 17 | env.js 18 | env.yml 19 | env.json 20 | admin.env 21 | tmp 22 | *.pyc 23 | *.swp 24 | *.swo 25 | vendor 26 | ./bin/Debug/netcoreapp2.1/ 27 | ./bin/release/netcoreapp2.1/ 28 | -------------------------------------------------------------------------------- /aws-dotnet-rest-api-with-dynamodb/.gitignore: -------------------------------------------------------------------------------- 1 | git node_modules 2 | .serverless 3 | *.swp 4 | *.*~ 5 | project.lock.json 6 | .DS_Store 7 | *.pyc 8 | nupkg/ 9 | 10 | # Visual Studio Code 11 | .vscode 12 | 13 | # User-specific files 14 | *.suo 15 | *.user 16 | *.userosscache 17 | *.sln.docstates 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | build/ 27 | bld/ 28 | [Bb]in/ 29 | [Oo]bj/ 30 | [Oo]ut/ 31 | msbuild.log 32 | msbuild.err 33 | msbuild.wrn 34 | 35 | # Visual Studio 2015 36 | .vs/ 37 | 38 | env.configs.yml -------------------------------------------------------------------------------- /aws-dotnet-rest-api-with-dynamodb/src/DotNetServerless.Application/Entities/Item.cs: -------------------------------------------------------------------------------- 1 | using Amazon.DynamoDBv2.DataModel; 2 | 3 | namespace DotNetServerless.Application.Entities 4 | { 5 | public class Item 6 | { 7 | [DynamoDBHashKey] 8 | public string Id { get; set; } 9 | [DynamoDBRangeKey] 10 | public string Code { get; set; } 11 | [DynamoDBProperty] 12 | public string Description { get; set; } 13 | [DynamoDBProperty] 14 | public bool IsChecked { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aws-dotnet-rest-api-with-dynamodb/src/DotNetServerless.Application/Infrastructure/Configs/DynamoDbConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace DotNetServerless.Application.Infrastructure.Configs 2 | { 3 | 4 | public class DynamoDbConfiguration 5 | { 6 | public string TableName { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /aws-dotnet-rest-api-with-dynamodb/src/DotNetServerless.Application/Infrastructure/Repositories/IItemRepository.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using DotNetServerless.Application.Entities; 5 | 6 | namespace DotNetServerless.Application.Infrastructure.Repositories 7 | { 8 | public interface IItemRepository 9 | { 10 | Task> GetById(string id, CancellationToken cancellationToken); 11 | 12 | Task Save(Item item, CancellationToken cancellationToken); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /aws-dotnet-rest-api-with-dynamodb/src/DotNetServerless.Application/Requests/CreateItemRequest.cs: -------------------------------------------------------------------------------- 1 | using DotNetServerless.Application.Entities; 2 | using MediatR; 3 | 4 | namespace DotNetServerless.Application.Requests 5 | { 6 | public class CreateItemRequest : IRequest 7 | { 8 | public string Description { get; set; } 9 | public string Code { get; set; } 10 | public bool IsChecked { get; set; } 11 | 12 | public Item Map() 13 | { 14 | return new Item 15 | { 16 | Description = Description, 17 | Code = Code, 18 | IsChecked = IsChecked 19 | }; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /aws-dotnet-rest-api-with-dynamodb/src/DotNetServerless.Application/Requests/GetItemRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DotNetServerless.Application.Entities; 3 | using MediatR; 4 | 5 | namespace DotNetServerless.Application.Requests 6 | { 7 | public class GetItemRequest : IRequest 8 | { 9 | public Guid Id { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /aws-dotnet-rest-api-with-dynamodb/src/DotNetServerless.Application/Requests/UpdateItemRequest.cs: -------------------------------------------------------------------------------- 1 | using DotNetServerless.Application.Entities; 2 | using MediatR; 3 | 4 | namespace DotNetServerless.Application.Requests 5 | { 6 | public class UpdateItemRequest : IRequest 7 | { 8 | public string Id { get; set; } 9 | public string Description { get; set; } 10 | public string Code { get; set; } 11 | public bool IsChecked { get; set; } 12 | 13 | public Item Map() 14 | { 15 | return new Item 16 | { 17 | Id = Id, 18 | Description = Description, 19 | Code = Code, 20 | IsChecked = IsChecked 21 | }; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /aws-dotnet-rest-api-with-dynamodb/src/DotNetServerless.Application/Responses/ItemResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DotNetServerless.Application.Responses 4 | { 5 | public class ItemResponse 6 | { 7 | public Guid Id { get; set; } 8 | public string Code { get; set; } 9 | public string Description { get; set; } 10 | public bool IsChecked { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /aws-dotnet-rest-api-with-dynamodb/src/DotNetServerless.Lambda/Extensions/ServicesExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using Microsoft.Extensions.DependencyInjection; 3 | 4 | namespace DotNetServerless.Lambda.Extensions 5 | { 6 | public static class ServiceCollectionExtensions 7 | { 8 | public static IServiceCollection BindAndConfigure(this IServiceCollection services, 9 | IConfigurationSection section, TConfig config) 10 | where TConfig : class, new() 11 | { 12 | section.Bind(config); 13 | services.AddSingleton(config); 14 | 15 | return services; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-dotnet-rest-api-with-dynamodb/src/DotNetServerless.Lambda/Program.cs: -------------------------------------------------------------------------------- 1 | namespace DotNetServerless.Lambda 2 | { 3 | public class Program 4 | { 5 | public static void Main(string[] args) 6 | { 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /aws-dotnet-rest-api-with-dynamodb/src/DotNetServerless.Lambda/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-dotnet-rest-api-with-dynamodb", 3 | "description": "Reading/Writing operations using .NET Core and DynamoDB", 4 | "author": "Samuele Resca ", 5 | "version": "1.0.0", 6 | "scripts": { 7 | "build": "dotnet restore && dotnet lambda package --configuration release --framework netcoreapp2.1 --output-package bin/release/netcoreapp2.1/deploy-package.zip", 8 | "test": " dotnet test ../../tests/DotNetServerless.Tests/DotNetServerless.Tests.csproj", 9 | "deploy": "npm run build && npm run test && node_modules/.bin/serverless deploy --verbose" 10 | }, 11 | "devDependencies": { 12 | "serverless": "^1.33.2" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /aws-ffmpeg-layer/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless/ 2 | node_modules/ 3 | layer/ 4 | -------------------------------------------------------------------------------- /aws-ffmpeg-layer/README.md: -------------------------------------------------------------------------------- 1 | 11 | 12 | # AWS FFmepg Layer & a service using it to create GIFs 13 | ``` 14 | git clone https://github.com/serverless/examples 15 | cd examples/aws-ffmpeg-layer 16 | ./build.sh 17 | sls deploy 18 | ``` 19 | 20 | See the blog post about this example for more details: 21 | https://serverless.com/blog/publish-aws-lambda-layers-serverless-framework/ 22 | -------------------------------------------------------------------------------- /aws-ffmpeg-layer/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p layer 3 | cd layer 4 | rm -rf * 5 | curl -O https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz 6 | tar -xf ffmpeg-git-amd64-static.tar.xz 7 | mv ffmpeg-git-*-amd64-static ffmpeg 8 | rm ffmpeg-git-amd64-static.tar.xz 9 | -------------------------------------------------------------------------------- /aws-ffmpeg-layer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-lambda-layer", 3 | "description": "", 4 | "version": "0.1.0", 5 | "dependencies": {}, 6 | "devDependencies": {} 7 | } 8 | -------------------------------------------------------------------------------- /aws-ffmpeg-layer/serverless.yml: -------------------------------------------------------------------------------- 1 | service: gifmaker 2 | frameworkVersion: ">=1.34.0 <2.0.0" 3 | 4 | provider: 5 | name: aws 6 | runtime: nodejs10.x 7 | iamRoleStatements: 8 | - Effect: Allow 9 | Action: 10 | - s3:PutObject 11 | - s3:GetObject 12 | Resource: "arn:aws:s3:::${self:custom.bucket}/*" 13 | 14 | functions: 15 | mkgif: 16 | handler: handler.mkgif 17 | events: 18 | - s3: ${self:custom.bucket} 19 | layers: 20 | - {Ref: FfmpegLambdaLayer} 21 | 22 | layers: 23 | ffmpeg: 24 | path: layer 25 | 26 | custom: 27 | bucket: ${env:BUCKET, 'ffmpeg-layer-gif-maker'} 28 | 29 | plugins: 30 | - serverless-localstack 31 | -------------------------------------------------------------------------------- /aws-golang-auth-examples/.gitignore: -------------------------------------------------------------------------------- 1 | bin/** 2 | vendor 3 | .serverless 4 | *.coverprofile 5 | -------------------------------------------------------------------------------- /aws-golang-auth-examples/Makefile: -------------------------------------------------------------------------------- 1 | help: 2 | @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' 3 | 4 | functions := $(shell find functions -name \*main.go | awk -F'/' '{print $$2}') 5 | 6 | build: ## Build golang binaries 7 | @for function in $(functions) ; do \ 8 | env GOOS=linux go build -ldflags="-s -w" -o bin/$$function functions/$$function/main.go ; \ 9 | done 10 | -------------------------------------------------------------------------------- /aws-golang-auth-examples/functions/auth/auth_suite_test.go: -------------------------------------------------------------------------------- 1 | package main_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestAuth(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Auth Suite") 13 | } 14 | -------------------------------------------------------------------------------- /aws-golang-auth-examples/functions/auth2/auth_suite_test.go: -------------------------------------------------------------------------------- 1 | package main_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestAuth(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Auth Suite") 13 | } 14 | -------------------------------------------------------------------------------- /aws-golang-auth-examples/functions/hello-world/hello_world_suite_test.go: -------------------------------------------------------------------------------- 1 | package main_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestHelloWorld(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "HelloWorld Suite") 13 | } 14 | -------------------------------------------------------------------------------- /aws-golang-auth-examples/functions/hello-world/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/aws/aws-lambda-go/events" 5 | "github.com/aws/aws-lambda-go/lambda" 6 | ) 7 | 8 | func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { 9 | return events.APIGatewayProxyResponse{ 10 | Body: "Hello, World!", 11 | StatusCode: 200, 12 | }, nil 13 | } 14 | 15 | func main() { 16 | lambda.Start(handler) 17 | } 18 | -------------------------------------------------------------------------------- /aws-golang-auth-examples/functions/hello-world/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/aws/aws-lambda-go/events" 7 | 8 | . "github.com/onsi/ginkgo" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | var _ = Describe("Hello world", func() { 13 | var ( 14 | response events.APIGatewayProxyResponse 15 | request events.APIGatewayProxyRequest 16 | err error 17 | ) 18 | 19 | JustBeforeEach(func() { 20 | response, err = handler(request) 21 | Expect(err).To(BeNil()) 22 | }) 23 | 24 | It(`Returns "Hello, World!" and an OK status`, func() { 25 | Expect(response.Body).To(Equal("Hello, World!")) 26 | Expect(response.StatusCode).To(Equal(http.StatusOK)) 27 | }) 28 | }) 29 | -------------------------------------------------------------------------------- /aws-golang-auth-examples/functions/hello-world2/hello_world_suite_test.go: -------------------------------------------------------------------------------- 1 | package main_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestHelloWorld(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "HelloWorld Suite") 13 | } 14 | -------------------------------------------------------------------------------- /aws-golang-auth-examples/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/srbry/go-serverless-example 2 | 3 | require ( 4 | github.com/aws/aws-lambda-go v1.6.0 5 | github.com/davecgh/go-spew v1.1.1 // indirect 6 | github.com/onsi/ginkgo v1.6.0 7 | github.com/onsi/gomega v1.4.2 8 | github.com/pmezard/go-difflib v1.0.0 // indirect 9 | github.com/stretchr/testify v1.2.2 // indirect 10 | golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3 // indirect 11 | golang.org/x/sys v0.0.0-20180928133829-e4b3c5e90611 // indirect 12 | ) 13 | -------------------------------------------------------------------------------- /aws-golang-auth-examples/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-golang-auth-examples", 3 | "version": "1.0.0", 4 | "description": "These example shows how to run a Golang lambda with authentication", 5 | "main": "", 6 | "keywords": [ 7 | "Go", 8 | "serverless", 9 | "aws", 10 | "dynamodb", 11 | "auth", 12 | "tdd", 13 | "test", 14 | "testing" 15 | ], 16 | "author": "Sam Bryant ", 17 | "license": "MIT", 18 | "devDependencies": { 19 | "serverless": "^1.30.3" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aws-golang-dynamo-stream-to-elasticsearch/Makefile: -------------------------------------------------------------------------------- 1 | build: 2 | dep ensure 3 | 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 4 | 5 | .PHONY: clean 6 | clean: 7 | rm -rf ./bin ./vendor Gopkg.lock 8 | 9 | .PHONY: deploy 10 | deploy: clean build 11 | sls deploy --verbose 12 | -------------------------------------------------------------------------------- /aws-golang-dynamo-stream-to-elasticsearch/docs/kibana.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localstack/serverless-examples/c4874f3cb38d67d64f90cc2d444941c55d8064b9/aws-golang-dynamo-stream-to-elasticsearch/docs/kibana.png -------------------------------------------------------------------------------- /aws-golang-dynamo-stream-to-elasticsearch/docs/query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localstack/serverless-examples/c4874f3cb38d67d64f90cc2d444941c55d8064b9/aws-golang-dynamo-stream-to-elasticsearch/docs/query.png -------------------------------------------------------------------------------- /aws-golang-dynamo-stream-to-elasticsearch/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-golang-dynamo-stream-to-elasticsearch", 3 | "version": "1.0.0", 4 | "description": "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", 5 | "main": "", 6 | "keywords": ["Go","serverless","aws","dynamodb","elasticsearch"], 7 | "author": "Brian Jones ", 8 | "license": "MIT", 9 | "devDependencies": { 10 | "serverless": "^1.30.3" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /aws-golang-googlemap/Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | digest = "1:4775daf89638182e60b52ca32dacecb030aff6f9dcecb28af389f6e8aa807ac7" 6 | name = "github.com/aws/aws-lambda-go" 7 | packages = [ 8 | "events", 9 | "lambda", 10 | "lambda/messages", 11 | "lambdacontext", 12 | ] 13 | pruneopts = "" 14 | revision = "527f5d301d2993af078be6d0b63372786b3fc18f" 15 | version = "v1.8.2" 16 | 17 | [solve-meta] 18 | analyzer-name = "dep" 19 | analyzer-version = 1 20 | input-imports = [ 21 | "github.com/aws/aws-lambda-go/events", 22 | "github.com/aws/aws-lambda-go/lambda", 23 | ] 24 | solver-name = "gps-cdcl" 25 | solver-version = 1 26 | -------------------------------------------------------------------------------- /aws-golang-googlemap/Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Gopkg.toml example 2 | # 3 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 4 | # for detailed Gopkg.toml documentation. 5 | # 6 | # required = ["github.com/user/thing/cmd/thing"] 7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 8 | # 9 | # [[constraint]] 10 | # name = "github.com/user/project" 11 | # version = "1.0.0" 12 | # 13 | # [[constraint]] 14 | # name = "github.com/user/project2" 15 | # branch = "dev" 16 | # source = "github.com/myfork/project2" 17 | # 18 | # [[override]] 19 | # name = "github.com/x/y" 20 | # version = "2.4.0" 21 | 22 | 23 | [[constraint]] 24 | name = "github.com/aws/aws-lambda-go" 25 | version = "1.x" 26 | -------------------------------------------------------------------------------- /aws-golang-googlemap/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build clean deploy 2 | 3 | build: 4 | dep ensure -v 5 | env GOOS=linux go build -ldflags="-s -w" -o bin/getgeolocation getgeolocation/main.go 6 | env GOOS=linux go build -ldflags="-s -w" -o bin/getsearchlocation getsearchlocation/main.go 7 | env GOOS=linux go build -ldflags="-s -w" -o bin/getnearbylocation getnearbylocation/main.go 8 | env GOOS=linux go build -ldflags="-s -w" -o bin/getgeodetail getgeodetail/main.go 9 | 10 | clean: 11 | rm -rf ./bin ./vendor Gopkg.lock 12 | 13 | deploy: clean build 14 | sls deploy --verbose 15 | -------------------------------------------------------------------------------- /aws-golang-http-get-post/Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | digest = "1:1c29e45ea5c6fa7e9159bfed0f5b31f10030f536ebc7f87615b93ff5f20c6dfe" 6 | name = "github.com/aws/aws-lambda-go" 7 | packages = [ 8 | "events", 9 | "lambda", 10 | "lambda/messages", 11 | "lambdacontext", 12 | ] 13 | pruneopts = "" 14 | revision = "928161204cad89472f9e6b5dd49ce16bc91230de" 15 | version = "v1.8.1" 16 | 17 | [solve-meta] 18 | analyzer-name = "dep" 19 | analyzer-version = 1 20 | input-imports = [ 21 | "github.com/aws/aws-lambda-go/events", 22 | "github.com/aws/aws-lambda-go/lambda", 23 | ] 24 | solver-name = "gps-cdcl" 25 | solver-version = 1 26 | -------------------------------------------------------------------------------- /aws-golang-http-get-post/Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Gopkg.toml example 2 | # 3 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 4 | # for detailed Gopkg.toml documentation. 5 | # 6 | # required = ["github.com/user/thing/cmd/thing"] 7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 8 | # 9 | # [[constraint]] 10 | # name = "github.com/user/project" 11 | # version = "1.0.0" 12 | # 13 | # [[constraint]] 14 | # name = "github.com/user/project2" 15 | # branch = "dev" 16 | # source = "github.com/myfork/project2" 17 | # 18 | # [[override]] 19 | # name = "github.com/x/y" 20 | # version = "2.4.0" 21 | 22 | 23 | [[constraint]] 24 | name = "github.com/aws/aws-lambda-go" 25 | version = "1.x" 26 | -------------------------------------------------------------------------------- /aws-golang-http-get-post/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build clean deploy 2 | 3 | build: 4 | dep ensure -v 5 | env GOOS=linux go build -ldflags="-s -w" -o bin/getBin getFolder/getExample.go 6 | env GOOS=linux go build -ldflags="-s -w" -o bin/postBin postFolder/postExample.go 7 | env GOOS=linux go build -ldflags="-s -w" -o bin/getQueryBin getFolder/getQueryExample.go 8 | 9 | clean: 10 | rm -rf ./bin ./vendor Gopkg.lock 11 | 12 | deploy: clean build 13 | sls deploy --verbose 14 | -------------------------------------------------------------------------------- /aws-golang-http-get-post/getFolder/getExample.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/aws/aws-lambda-go/events" 7 | "github.com/aws/aws-lambda-go/lambda" 8 | ) 9 | 10 | // Handler function Using AWS Lambda Proxy Request 11 | func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { 12 | 13 | //Get the path parameter that was sent 14 | name := request.PathParameters["name"] 15 | 16 | //Generate message that want to be sent as body 17 | message := fmt.Sprintf(" { \"Message\" : \"Hello %s \" } ", name) 18 | 19 | //Returning response with AWS Lambda Proxy Response 20 | return events.APIGatewayProxyResponse{Body: message, StatusCode: 200}, nil 21 | } 22 | 23 | func main() { 24 | lambda.Start(Handler) 25 | } 26 | -------------------------------------------------------------------------------- /aws-golang-http-get-post/getFolder/getQueryExample.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/aws/aws-lambda-go/events" 7 | "github.com/aws/aws-lambda-go/lambda" 8 | ) 9 | 10 | // Handler function Using AWS Lambda Proxy Request 11 | func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { 12 | 13 | //Get the path parameter that was sent 14 | name := request.QueryStringParameters["name"] 15 | 16 | //Generate message that want to be sent as body 17 | message := fmt.Sprintf(" { \"Message\" : \"Hello %s \" } ", name) 18 | 19 | //Returning response with AWS Lambda Proxy Response 20 | return events.APIGatewayProxyResponse{Body: message, StatusCode: 200}, nil 21 | } 22 | 23 | func main() { 24 | lambda.Start(Handler) 25 | } 26 | -------------------------------------------------------------------------------- /aws-golang-http-get-post/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-golang-http-get-post", 3 | "version": "1.29.2", 4 | "description": "Example on Making Parameterized Get and Post Request with Golang", 5 | "author": "Pramono Winata ", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-golang-simple-http-endpoint/Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Gopkg.toml example 2 | # 3 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 4 | # for detailed Gopkg.toml documentation. 5 | # 6 | # required = ["github.com/user/thing/cmd/thing"] 7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 8 | # 9 | # [[constraint]] 10 | # name = "github.com/user/project" 11 | # version = "1.0.0" 12 | # 13 | # [[constraint]] 14 | # name = "github.com/user/project2" 15 | # branch = "dev" 16 | # source = "github.com/myfork/project2" 17 | # 18 | # [[override]] 19 | # name = "github.com/x/y" 20 | # version = "2.4.0" 21 | 22 | 23 | [[constraint]] 24 | name = "github.com/aws/aws-lambda-go" 25 | version = "1.x" 26 | -------------------------------------------------------------------------------- /aws-golang-simple-http-endpoint/Makefile: -------------------------------------------------------------------------------- 1 | build: 2 | dep ensure -v 3 | env GOOS=linux go build -ldflags="-s -w" -o bin/hello hello/main.go 4 | env GOOS=linux go build -ldflags="-s -w" -o bin/world world/main.go 5 | 6 | .PHONY: clean 7 | clean: 8 | rm -rf ./bin ./vendor Gopkg.lock 9 | 10 | .PHONY: deploy 11 | deploy: clean build 12 | sls deploy --verbose 13 | -------------------------------------------------------------------------------- /aws-golang-simple-http-endpoint/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /aws-golang-simple-http-endpoint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-golang-simple-http-endpoint", 3 | "version": "0.0.1", 4 | "description": "Example demonstrates how to setup a simple HTTP GET endpoint with golang", 5 | "author": "Sebastian Borza ", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-golang-simple-http-endpoint/serverless.yml: -------------------------------------------------------------------------------- 1 | service: aws-golang-simple-http-endpoint 2 | 3 | frameworkVersion: ">=1.28.0 <2.0.0" 4 | 5 | provider: 6 | name: aws 7 | runtime: go1.x 8 | 9 | functions: 10 | hello: 11 | handler: bin/hello 12 | events: 13 | - http: 14 | path: hello 15 | method: get 16 | world: 17 | handler: bin/world 18 | events: 19 | - http: 20 | path: world 21 | method: get 22 | 23 | package: 24 | exclude: 25 | - ./** 26 | include: 27 | - ./bin/** 28 | -------------------------------------------------------------------------------- /aws-golang-stream-kinesis-to-elasticsearch/Makefile: -------------------------------------------------------------------------------- 1 | build: 2 | dep ensure -v 3 | env GOOS=linux go build -ldflags="-s -w" -o bin/stream main.go 4 | 5 | .PHONY: clean 6 | clean: 7 | rm -rf ./bin ./vendor 8 | 9 | .PHONY: deploy 10 | deploy: clean build 11 | sls deploy --verbose 12 | -------------------------------------------------------------------------------- /aws-golang-stream-kinesis-to-elasticsearch/README.md: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /aws-golang-stream-kinesis-to-elasticsearch/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "os" 6 | 7 | "github.com/aws/aws-lambda-go/events" 8 | "github.com/aws/aws-lambda-go/lambda" 9 | 10 | elastic "github.com/serverless/examples/aws-golang-stream-kinesis-to-elasticsearch/elastic" 11 | ) 12 | 13 | func handler(ctx context.Context, event events.KinesisEvent) error { 14 | client, err := elastic.NewClient(os.Getenv("ELASTICSEARCH_HOST"), os.Getenv("ELASTICSEARCH_SCHEMA")) 15 | if err != nil { 16 | return err 17 | } 18 | 19 | return client.PushRecords(event.Records) 20 | } 21 | 22 | func main() { 23 | lambda.Start(handler) 24 | } 25 | -------------------------------------------------------------------------------- /aws-golang-stream-kinesis-to-elasticsearch/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-golang-stream-kinesis-to-elasticsearch", 3 | "version": "0.0.1", 4 | "description": "Pull data from AWS Kinesis streams and forward to elasticsearch", 5 | "author": "Sebastian Borza ", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-golang-stream-kinesis-to-elasticsearch/serverless.yml: -------------------------------------------------------------------------------- 1 | service: aws-golang-kinesis-to-elasticsearch 2 | 3 | frameworkVersion: ">=1.28.0 <2.0.0" 4 | 5 | provider: 6 | name: aws 7 | runtime: go1.x 8 | environment: 9 | ELASTICSEARCH_HOST: my.elastic.host 10 | ELASTICSEARCH_SCHEMA: http 11 | 12 | functions: 13 | streamer: 14 | handler: bin/stream 15 | events: 16 | - stream: 17 | type: kinesis 18 | arn: arn:aws:kinesis:::stream/ 19 | batchSize: 100 20 | startingPosition: TRIM_HORIZON 21 | enabled: true 22 | 23 | package: 24 | exclude: 25 | - ./** 26 | include: 27 | - ./bin/** 28 | -------------------------------------------------------------------------------- /aws-java-simple-http-endpoint/.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | .gradle 3 | /build/ 4 | /bin/ 5 | /.settings/ 6 | .project 7 | .classpath 8 | target 9 | 10 | # Package Files 11 | *.jar 12 | *.war 13 | *.ear 14 | 15 | # Serverless directories 16 | .serverless 17 | -------------------------------------------------------------------------------- /aws-java-simple-http-endpoint/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Jan 14 14:33:39 PST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-bin.zip 7 | -------------------------------------------------------------------------------- /aws-java-simple-http-endpoint/serverless.yml: -------------------------------------------------------------------------------- 1 | service: aws-java-simple-http-endpoint 2 | 3 | frameworkVersion: ">=1.2.0 <2.0.0" 4 | 5 | provider: 6 | name: aws 7 | runtime: java8 8 | 9 | package: 10 | artifact: build/distributions/aws-java-simple-http-endpoint.zip 11 | 12 | functions: 13 | currentTime: 14 | handler: com.serverless.Handler 15 | events: 16 | - http: 17 | path: ping 18 | method: get 19 | -------------------------------------------------------------------------------- /aws-java-simple-http-endpoint/src/main/java/com/serverless/Response.java: -------------------------------------------------------------------------------- 1 | package com.serverless; 2 | 3 | public class Response { 4 | 5 | private final String message; 6 | 7 | public Response(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return this.message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /aws-java-simple-http-endpoint/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log = . 2 | log4j.rootLogger = DEBUG, LAMBDA 3 | 4 | log4j.appender.LAMBDA=com.amazonaws.services.lambda.runtime.log4j.LambdaAppender 5 | log4j.appender.LAMBDA.layout=org.apache.log4j.PatternLayout 6 | log4j.appender.LAMBDA.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss} <%X{AWSRequestId}> %-5p %c:%L - %m%n 7 | -------------------------------------------------------------------------------- /aws-multiple-runtime/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /aws-multiple-runtime/api/.gitignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless -------------------------------------------------------------------------------- /aws-multiple-runtime/api/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports.timestamp = (event, context, callback) => { 4 | const response = { 5 | statusCode: 200, 6 | headers: { 7 | 'Content-Type': 'text/plain', 8 | }, 9 | body: parseInt(Date.now() / 1000, 10), 10 | }; 11 | 12 | callback(null, response); 13 | }; 14 | -------------------------------------------------------------------------------- /aws-multiple-runtime/serverless.yml: -------------------------------------------------------------------------------- 1 | service: hellotime-app 2 | provider: 3 | name: aws 4 | 5 | functions: 6 | hello: 7 | runtime: python3.6 8 | events: 9 | - http: 10 | method: get 11 | path: greet 12 | handler: web/handler.hello 13 | time: 14 | runtime: nodejs6.10 15 | events: 16 | - http: 17 | method: get 18 | path: time 19 | handler: api/handler.timestamp 20 | -------------------------------------------------------------------------------- /aws-multiple-runtime/web/handler.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | import http.client 3 | 4 | def hello(event, context): 5 | rc = event["requestContext"] 6 | servicePath = rc["path"][:-len(rc["resourcePath"])] # path minus the resource path '/greet' 7 | 8 | # GET from the /time endpoint 9 | connection = http.client.HTTPSConnection(event["headers"]["Host"]) 10 | connection.request("GET", "{0}/time".format(servicePath)) 11 | timestamp = connection.getresponse().read().decode() 12 | timeStr = datetime.fromtimestamp(int(timestamp)).strftime("%B %d, %Y") 13 | 14 | return { 15 | "statusCode": 200, 16 | "body": "

Hello! It is now {0}.

".format(timeStr), 17 | "headers": { 18 | "Content-Type": "text/html" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /aws-node-alexa-skill/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-alexa-skill/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // Returns a random integer between min (inclusive) and max (inclusive) 4 | const getRandomInt = (min, max) => Math.floor(Math.random() * ((max - min) + 1)) + min; 5 | 6 | module.exports.luckyNumber = (event, context, callback) => { 7 | const upperLimit = event.request.intent.slots.UpperLimit.value || 100; 8 | const number = getRandomInt(0, upperLimit); 9 | const response = { 10 | version: '1.0', 11 | response: { 12 | outputSpeech: { 13 | type: 'PlainText', 14 | text: `Your lucky number is ${number}`, 15 | }, 16 | shouldEndSession: false, 17 | }, 18 | }; 19 | 20 | callback(null, response); 21 | }; 22 | -------------------------------------------------------------------------------- /aws-node-alexa-skill/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-alexa-skill", 3 | "version": "1.0.0", 4 | "description": "This example demonstrates how to use an AWS Lambdas for your custom Alexa skill.", 5 | "author": "", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-node-alexa-skill/serverless.yml: -------------------------------------------------------------------------------- 1 | service: aws-node-alexa-skill 2 | 3 | frameworkVersion: ">=1.4.0 <2.0.0" 4 | 5 | provider: 6 | name: aws 7 | runtime: nodejs8.10 8 | 9 | functions: 10 | luckyNumber: 11 | handler: handler.luckyNumber 12 | events: 13 | - alexaSkill 14 | -------------------------------------------------------------------------------- /aws-node-auth0-cognito-custom-authorizers-api/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-auth0-cognito-custom-authorizers-api/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // Public API 4 | module.exports.publicEndpoint = (event, context, cb) => { 5 | cb(null, { message: 'Welcome to our Public API!' }); 6 | }; 7 | 8 | // Private API 9 | module.exports.privateEndpoint = (event, context, cb) => { 10 | cb(null, { message: 'Only logged in users can see this' }); 11 | }; 12 | -------------------------------------------------------------------------------- /aws-node-auth0-cognito-custom-authorizers-api/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-node-auth0-cognito-custom-authorizers-api", 3 | "version": "1.0.0", 4 | "description": "Authorize your API Gateway with either Auth0 or Cognito RS256 tokens.", 5 | "license": "MIT", 6 | "dependencies": { 7 | "jsonwebtoken": "^7.1.9", 8 | "jwk-to-pem": "^1.2.6", 9 | "request": "^2.82.0" 10 | }, 11 | "author": "Shahzeb Khan" 12 | } 13 | -------------------------------------------------------------------------------- /aws-node-auth0-custom-authorizers-api/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | secrets.json 4 | public_key 5 | /frontend/misc.md 6 | -------------------------------------------------------------------------------- /aws-node-auth0-custom-authorizers-api/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-auth0-api-gateway", 3 | "version": "1.0.0", 4 | "description": "Demonstration of protecting API gateway endpoints with auth0", 5 | "license": "MIT", 6 | "dependencies": { 7 | "jsonwebtoken": "^8.1.0" 8 | }, 9 | "devDependencies": { 10 | "serverless-offline": "^3.18.0" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /aws-node-auth0-custom-authorizers-api/public_key-example: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | PUBLIC KEY - can be found in `https://manage.auth0.com -> applications->${YOUR_APP_NAME}->settings->Show Advanced Settings->Certificates->DOWNLOAD CERTIFICATE.` 3 | You should download the certificate in PEM format and save it as a new file called `public_key` 4 | -----END CERTIFICATE----- 5 | -------------------------------------------------------------------------------- /aws-node-auth0-custom-authorizers-api/secrets.example.json: -------------------------------------------------------------------------------- 1 | { 2 | "AUTH0_CLIENT_ID": "your-client-id" 3 | } 4 | -------------------------------------------------------------------------------- /aws-node-dynamic-image-resizer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM amazonlinux 2 | WORKDIR /deploy 3 | RUN yum -y install make gcc* 4 | RUN curl --silent --location https://rpm.nodesource.com/setup_8.x | bash - 5 | RUN yum -y install nodejs 6 | RUN npm install -g serverless 7 | COPY . . 8 | RUN npm i --production 9 | 10 | RUN ["chmod", "+x", "deploy.sh"] 11 | CMD ./deploy.sh ; sleep 2m 12 | -------------------------------------------------------------------------------- /aws-node-dynamic-image-resizer/config/.env.example: -------------------------------------------------------------------------------- 1 | STAGE=dev-1 2 | PROFILE= 3 | REGION=us-east-1 4 | -------------------------------------------------------------------------------- /aws-node-dynamic-image-resizer/config/pull-secret.sh: -------------------------------------------------------------------------------- 1 | echo "🔍 $(tput bold)Pull secret$(tput sgr0)" 2 | 3 | if [ "$#" -lt 1 ]; then 4 | printf "Secret key: " 5 | read key 6 | else 7 | key=$1 8 | fi; 9 | 10 | aws ssm get-parameter --name $key --region us-east-1 --with-decryption 11 | -------------------------------------------------------------------------------- /aws-node-dynamic-image-resizer/config/push-secret.sh: -------------------------------------------------------------------------------- 1 | echo "💾 $(tput bold)Push secret$(tput sgr0)" 2 | 3 | if [ "$#" -lt 2 ]; then 4 | printf "Secret key: " 5 | read key 6 | printf "Secret value: " 7 | read value 8 | else 9 | value=$1 10 | key=$2 11 | fi; 12 | 13 | aws ssm put-parameter --name $key --value $value --type SecureString --region us-east-1 --overwrite 14 | -------------------------------------------------------------------------------- /aws-node-dynamic-image-resizer/deploy.sh: -------------------------------------------------------------------------------- 1 | stage=${STAGE} 2 | region=${REGION} 3 | bucket=${BUCKET} 4 | secrets='/deploy/secrets/secrets.json' 5 | 6 | sls config credentials \ 7 | --provider aws \ 8 | --key ${SLS_KEY} \ 9 | --secret ${SLS_SECRET} \ 10 | --profile ${PROFILE} 11 | 12 | echo 'Deploying' 13 | sls deploy -s ${STAGE} 14 | -------------------------------------------------------------------------------- /aws-node-dynamic-image-resizer/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | image-resize: 4 | build: . 5 | volumes: 6 | - ./secrets:/deploy/secrets 7 | env_file: 8 | - ./secrets/secrets.env 9 | -------------------------------------------------------------------------------- /aws-node-dynamic-image-resizer/secrets/secrets.env: -------------------------------------------------------------------------------- 1 | SLS_KEY= 2 | SLS_SECRET= 3 | PROFILE= 4 | STAGE=dev-1 5 | REGION=us-east-1 6 | -------------------------------------------------------------------------------- /aws-node-dynamic-image-resizer/secrets/secrets.json: -------------------------------------------------------------------------------- 1 | {"DOMAIN":""} 2 | -------------------------------------------------------------------------------- /aws-node-dynamic-image-resizer/src/handlers/resizer/index.js: -------------------------------------------------------------------------------- 1 | import { resizeHandler } from './resizeHandler' 2 | 3 | export const handler = async (event) => { 4 | try { 5 | const imagePath = await resizeHandler._process(event) 6 | const URL = `http://${process.env.BUCKET}.s3-website.${process.env.REGION}.amazonaws.com` 7 | 8 | return { 9 | headers: { 'location': `${URL}/${imagePath}` }, 10 | statusCode: 301, 11 | body: '' 12 | } 13 | } catch (error) { 14 | console.log(error) 15 | return new Error(error) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /aws-node-dynamic-image-resizer/src/handlers/resizer/s3Handler.js: -------------------------------------------------------------------------------- 1 | import * as AWS from 'aws-sdk' 2 | import stream from 'stream' 3 | 4 | AWS.config.region = 'us-east-1' 5 | const S3 = new AWS.S3() 6 | 7 | class S3Handler { 8 | constructor() { } 9 | 10 | readStream({ Bucket, Key }) { 11 | return S3.getObject({ Bucket, Key }).createReadStream() 12 | } 13 | 14 | writeStream({ Bucket, Key }) { 15 | const passThrough = new stream.PassThrough() 16 | return { 17 | writeStream: passThrough, 18 | uploaded: S3.upload({ 19 | ContentType: 'image/png', 20 | Body: passThrough, 21 | Bucket, 22 | Key 23 | }).promise() 24 | } 25 | } 26 | } 27 | 28 | export const s3Handler = new S3Handler() 29 | -------------------------------------------------------------------------------- /aws-node-dynamic-image-resizer/src/lib/BaseHandler.js: -------------------------------------------------------------------------------- 1 | export default class BaseHandler { 2 | constructor() { 3 | this.handlerName = this.constructor.name 4 | } 5 | 6 | async execute(event, context) { 7 | console.log(`Executing handler ${this.handlerName}`) 8 | return this._process(event, context) 9 | } 10 | 11 | async _process(event, context) { 12 | console.log(event) 13 | console.log(context) 14 | console.log('Remember to overwrite this method if you need to provide custom handling logic.') 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aws-node-dynamic-image-resizer/webpack.config.js: -------------------------------------------------------------------------------- 1 | const slsw = require('serverless-webpack') 2 | const webpack = require('webpack') 3 | 4 | module.exports = { 5 | entry: slsw.lib.entries, 6 | target: 'node', 7 | mode: 'development', 8 | devtool: 'source-map', 9 | optimization: { 10 | minimize: false 11 | }, 12 | module: { 13 | rules: [ 14 | { 15 | test: /\.js$/, 16 | loaders: ['babel-loader'], 17 | include: __dirname, 18 | exclude: /node_modules/ 19 | } 20 | ] 21 | }, 22 | externals: ['sharp', 'aws-sdk'] 23 | } 24 | -------------------------------------------------------------------------------- /aws-node-dynamodb-backup/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-node-dynamodb-backup", 3 | "version": "1.0.0", 4 | "description": "Serverless DynamoDB changes backed up to S3", 5 | "repository": "", 6 | "author": "Kai Hendry ", 7 | "license": "MIT", 8 | "dependencies": { 9 | "aws-sdk": "^2.73.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /aws-node-env-variables-encrypted-in-a-file/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-env-variables-encrypted-in-a-file/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports.resetPassword = (event, context, callback) => { 4 | console.log('SESSION_KEY: ', process.env.SESSION_KEY); 5 | 6 | // Authenticate the user session 7 | 8 | console.log('EMAIL_SERVICE_API_KEY: ', process.env.EMAIL_SERVICE_API_KEY); 9 | 10 | // The email service api key would be used to send a reset password email. 11 | 12 | const response = { 13 | statusCode: 200, 14 | body: JSON.stringify({ 15 | message: 'Password sent.', 16 | }), 17 | }; 18 | 19 | callback(null, response); 20 | }; 21 | -------------------------------------------------------------------------------- /aws-node-env-variables-encrypted-in-a-file/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-env-variables-encrypted-in-a-file", 3 | "version": "1.0.0", 4 | "description": "Serverless example managing secrets in an encrypted file", 5 | "author": "", 6 | "license": "MIT", 7 | "dependencies": { 8 | "serverless-secrets-plugin": "^0.0.1" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aws-node-env-variables-encrypted-in-a-file/secrets.dev.yml.encrypted: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localstack/serverless-examples/c4874f3cb38d67d64f90cc2d444941c55d8064b9/aws-node-env-variables-encrypted-in-a-file/secrets.dev.yml.encrypted -------------------------------------------------------------------------------- /aws-node-env-variables-encrypted-in-a-file/secrets.prod.yml.encrypted: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localstack/serverless-examples/c4874f3cb38d67d64f90cc2d444941c55d8064b9/aws-node-env-variables-encrypted-in-a-file/secrets.prod.yml.encrypted -------------------------------------------------------------------------------- /aws-node-env-variables-encrypted-in-a-file/serverless.yml: -------------------------------------------------------------------------------- 1 | service: env-variables-encrypted-in-a-file 2 | 3 | frameworkVersion: ">=1.2.0 <2.0.0" 4 | 5 | plugins: 6 | - serverless-secrets-plugin 7 | 8 | provider: 9 | name: aws 10 | runtime: nodejs8.10 11 | stage: dev 12 | 13 | custom: 14 | secrets: ${file(secrets.${opt:stage, self:provider.stage}.yml)} 15 | 16 | functions: 17 | resetPassword: 18 | handler: handler.resetPassword 19 | environment: 20 | SESSION_KEY: ${self:custom.secrets.SESSION_KEY} 21 | EMAIL_SERVICE_API_KEY: ${self:custom.secrets.EMAIL_SERVICE_API_KEY} 22 | -------------------------------------------------------------------------------- /aws-node-env-variables/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-env-variables/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-env-variables", 3 | "version": "1.0.0", 4 | "description": "This example demonstrates how to use environment variables for AWS Lambdas.", 5 | "author": "", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-node-env-variables/serverless.yml: -------------------------------------------------------------------------------- 1 | service: function-with-environment-variables 2 | 3 | frameworkVersion: ">=1.2.0 <2.0.0" 4 | 5 | provider: 6 | name: aws 7 | runtime: nodejs8.10 8 | environment: 9 | EMAIL_SERVICE_API_KEY: KEYEXAMPLE1234 10 | 11 | functions: 12 | createUser: 13 | handler: handler.createUser 14 | environment: 15 | PASSWORD_ITERATIONS: 4096 16 | PASSWORD_DERIVED_KEY_LENGTH: 256 17 | 18 | resetPassword: 19 | handler: handler.resetPassword 20 | -------------------------------------------------------------------------------- /aws-node-fetch-file-and-store-in-s3/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-fetch-file-and-store-in-s3/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-fetch-file-and-store-in-s3", 3 | "description": "Fetch an image from remote source (URL) and then upload the image to a S3 bucket.", 4 | "version": "1.0.0", 5 | "author": "Bozhao Yu", 6 | "license": "MIT", 7 | "dependencies": { 8 | "aws-sdk": "^2.7.9", 9 | "node-fetch": "^1.6.3" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /aws-node-fetch-file-and-store-in-s3/serverless.yml: -------------------------------------------------------------------------------- 1 | service: fetch-file-and-store-in-s3 2 | 3 | frameworkVersion: ">=1.1.0" 4 | 5 | custom: 6 | bucket: 7 | 8 | provider: 9 | name: aws 10 | runtime: nodejs8.10 11 | stage: dev 12 | region: us-west-1 13 | iamRoleStatements: 14 | - Effect: Allow 15 | Action: 16 | - s3:PutObject 17 | - s3:PutObjectAcl 18 | Resource: "arn:aws:s3:::${self:custom.bucket}/*" 19 | 20 | functions: 21 | save: 22 | handler: handler.save 23 | environment: 24 | BUCKET: ${self:custom.bucket} 25 | -------------------------------------------------------------------------------- /aws-node-fullstack/backend/.gitignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless -------------------------------------------------------------------------------- /aws-node-fullstack/backend/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Form Submit 3 | */ 4 | 5 | const submit = (event, context, callback) => { 6 | 7 | if (event['queryStringParameters'] && event['queryStringParameters']['error']) { 8 | let r = Math.random().toString(36).substring(7); 9 | throw new Error(`Random error ${r}`) 10 | } 11 | 12 | callback(null, { 13 | statusCode: 200, 14 | headers: { 15 | 'Access-Control-Allow-Origin': '*', 16 | 'Access-Control-Allow-Credentials': true, 17 | }, 18 | body: JSON.stringify({ message: 'form submission received' }), 19 | }) 20 | } 21 | 22 | module.exports = { submit } 23 | -------------------------------------------------------------------------------- /aws-node-fullstack/backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sfe-demo-leadcapture", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": {}, 7 | "author": "Serverless.com", 8 | "license": "MIT", 9 | "dependencies": { 10 | "js-yaml": "^3.13.0", 11 | "serverless-finch": "^2.3.2" 12 | }, 13 | "devDependencies": { 14 | "@serverless/enterprise-plugin": "latest" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aws-node-fullstack/frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /aws-node-fullstack/frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "react": "^16.8.4", 7 | "react-dom": "^16.8.4", 8 | "react-scripts": "2.1.8" 9 | }, 10 | "scripts": { 11 | "start": "react-scripts start", 12 | "build": "react-scripts build", 13 | "test": "react-scripts test", 14 | "eject": "react-scripts eject" 15 | }, 16 | "eslintConfig": { 17 | "extends": "react-app" 18 | }, 19 | "browserslist": [ 20 | ">0.2%", 21 | "not dead", 22 | "not ie <= 11", 23 | "not op_mini all" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /aws-node-fullstack/frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localstack/serverless-examples/c4874f3cb38d67d64f90cc2d444941c55d8064b9/aws-node-fullstack/frontend/public/favicon.ico -------------------------------------------------------------------------------- /aws-node-fullstack/frontend/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /aws-node-fullstack/frontend/src/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localstack/serverless-examples/c4874f3cb38d67d64f90cc2d444941c55d8064b9/aws-node-fullstack/frontend/src/images/logo.png -------------------------------------------------------------------------------- /aws-node-fullstack/frontend/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 5 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 6 | sans-serif; 7 | -webkit-font-smoothing: antialiased; 8 | -moz-osx-font-smoothing: grayscale; 9 | } 10 | 11 | code { 12 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 13 | monospace; 14 | } 15 | -------------------------------------------------------------------------------- /aws-node-fullstack/frontend/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom' 3 | import DemoApp from './DemoApp' 4 | import './index.css' 5 | 6 | window.demoapp = {} 7 | 8 | ReactDOM.render(, document.getElementById('root')) 9 | -------------------------------------------------------------------------------- /aws-node-function-compiled-with-babel/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-function-compiled-with-babel/createResponse.js: -------------------------------------------------------------------------------- 1 | module.exports = ({ body = {}, statusCode = 200 }) => { 2 | const response = { 3 | statusCode, 4 | body, 5 | }; 6 | return response; 7 | }; 8 | -------------------------------------------------------------------------------- /aws-node-function-compiled-with-babel/event.json: -------------------------------------------------------------------------------- 1 | { 2 | "key3": "value3", 3 | "key2": "value2", 4 | "key1": "value1" 5 | } 6 | -------------------------------------------------------------------------------- /aws-node-function-compiled-with-babel/handler.js: -------------------------------------------------------------------------------- 1 | const createResponse = require('./createResponse'); 2 | 3 | module.exports.hello = (event, context, callback) => { 4 | const response = createResponse({ body: { message: 'Success!' } }); 5 | console.log({ response }); 6 | callback(null, response); 7 | }; 8 | -------------------------------------------------------------------------------- /aws-node-function-compiled-with-babel/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-function-compiled-with-babel", 3 | "version": "1.0.0", 4 | "description": "Demonstrating how to compile all your code with Babel", 5 | "repository": "", 6 | "author": "", 7 | "license": "MIT", 8 | "devDependencies": { 9 | "babel-cli": "~6.18.0", 10 | "babel-preset-latest": "^6.16.0", 11 | "serverless-babel-plugin": "^0.1.3" 12 | }, 13 | "dependencies": {} 14 | } 15 | -------------------------------------------------------------------------------- /aws-node-function-compiled-with-babel/serverless.yml: -------------------------------------------------------------------------------- 1 | service: function-compiled-with-babel 2 | 3 | frameworkVersion: ">=1.1.0 <2.0.0" 4 | 5 | custom: 6 | babelPresets: 7 | - latest 8 | 9 | plugins: 10 | - serverless-babel-plugin 11 | 12 | provider: 13 | name: aws 14 | runtime: nodejs8.10 15 | 16 | functions: 17 | hello: 18 | handler: handler.hello 19 | -------------------------------------------------------------------------------- /aws-node-github-check/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["source-map-support", "transform-runtime"], 3 | "presets": [ 4 | ["env", { "node": "8.10" }], 5 | "stage-3" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /aws-node-github-check/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | node_modules 3 | .serverless 4 | .webpack 5 | -------------------------------------------------------------------------------- /aws-node-github-check/libs/github-service.js: -------------------------------------------------------------------------------- 1 | export function isAValidPullRequest(body) { 2 | return body.pull_request.body.startsWith('Related trello card: https://trello.com'); 3 | } 4 | 5 | export function eventIsAPullRequest(body) { 6 | return body && ('pull_request' in body); 7 | } 8 | 9 | export function updatePullRequestStatus(githubClient, payload, repository, pullRequest) { 10 | return new Promise((resolve, reject) => { 11 | githubClient.post(`/repos/${repository.full_name}/statuses/${pullRequest.head.sha}`, payload, {}, (err) => { 12 | if (err) { 13 | reject(err); 14 | } else { 15 | resolve(); 16 | } 17 | }); 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /aws-node-github-check/libs/response-lib.js: -------------------------------------------------------------------------------- 1 | function buildResponse(statusCode, body) { 2 | return { 3 | statusCode, 4 | body: JSON.stringify(body), 5 | }; 6 | } 7 | 8 | function buildGithubPayload(state, description) { 9 | return { 10 | state, 11 | description, 12 | context: 'serverless-webhook/pr-body', 13 | }; 14 | } 15 | 16 | export function success(body) { 17 | return buildResponse(204, body); 18 | } 19 | 20 | export function failure(body) { 21 | return buildResponse(500, body); 22 | } 23 | 24 | export function githubSuccessPayload() { 25 | return buildGithubPayload('success', 'PR body according to format'); 26 | } 27 | 28 | export function githubFailurePayload() { 29 | return buildGithubPayload('failure', 'PR body should start with the related trello card'); 30 | } 31 | -------------------------------------------------------------------------------- /aws-node-github-check/serverless.yaml: -------------------------------------------------------------------------------- 1 | service: serverless-github-check 2 | 3 | plugins: 4 | - serverless-webpack 5 | - serverless-offline 6 | 7 | custom: 8 | webpack: 9 | webpackConfig: ./webpack.config.js 10 | includeModules: true 11 | 12 | provider: 13 | name: aws 14 | runtime: nodejs8.10 15 | profile: personal 16 | region: eu-west-1 17 | environment: 18 | GITHUB_TOKEN: ${ssm:githubToken} 19 | 20 | functions: 21 | githubCheck: 22 | handler: handler.githubCheck 23 | events: 24 | - http: 25 | path: webhook 26 | method: post 27 | cors: true 28 | -------------------------------------------------------------------------------- /aws-node-github-check/webpack.config.js: -------------------------------------------------------------------------------- 1 | const slsw = require('serverless-webpack'); 2 | const nodeExternals = require('webpack-node-externals'); 3 | 4 | module.exports = { 5 | entry: slsw.lib.entries, 6 | target: 'node', 7 | devtool: 'source-map', 8 | externals: [nodeExternals()], 9 | mode: slsw.lib.webpack.isLocal ? 'development' : 'production', 10 | optimization: { 11 | minimize: false, 12 | }, 13 | performance: { 14 | hints: false, 15 | }, 16 | module: { 17 | rules: [ 18 | { 19 | test: /\.js$/, 20 | loader: 'babel-loader', 21 | include: __dirname, 22 | exclude: /node_modules/, 23 | }, 24 | ], 25 | }, 26 | }; 27 | -------------------------------------------------------------------------------- /aws-node-github-webhook-listener/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-github-webhook-listener/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-github-webhook-listener", 3 | "version": "1.0.0", 4 | "description": "Extend your github repositories with this github webhook listener", 5 | "main": "handler.js", 6 | "scripts": { 7 | "deploy": "serverless deploy", 8 | "logs": "serverless logs -f githubWebhookListener -t" 9 | }, 10 | "author": "David Wells", 11 | "license": "MIT" 12 | } 13 | -------------------------------------------------------------------------------- /aws-node-github-webhook-listener/serverless.yml: -------------------------------------------------------------------------------- 1 | service: github-webhook-listener 2 | 3 | provider: 4 | name: aws 5 | runtime: nodejs8.10 6 | environment: 7 | GITHUB_WEBHOOK_SECRET: REPLACE-WITH-YOUR-SECRET-HERE 8 | 9 | functions: 10 | githubWebhookListener: 11 | handler: handler.githubWebhookListener 12 | events: 13 | - http: 14 | path: webhook 15 | method: post 16 | cors: true 17 | -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "graphql-api-and-serverless", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "handler.js", 6 | "scripts": { 7 | "func": "serverless deploy function --function graphql", 8 | "deploy": "serverless deploy", 9 | "remove": "serverless remove" 10 | }, 11 | "dependencies": { 12 | "graphql-yoga": "^1.17.4", 13 | "pg": "^7.11.0", 14 | "serverless-mysql": "^1.4.0", 15 | "uuid": "^3.3.2" 16 | }, 17 | "devDependencies": { 18 | "serverless-pseudo-parameters": "^2.4.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resolver/Query/aurora_getUser.js: -------------------------------------------------------------------------------- 1 | var common = require('../Common/aurora') 2 | const Client = require('serverless-mysql') 3 | exports.func = async (_, { uuid }) => { 4 | var client = Client({ 5 | config: { 6 | host: process.env.MYSQL_HOST, 7 | database: process.env.DB_NAME, 8 | user: process.env.USERNAME, 9 | password: process.env.PASSWORD 10 | } 11 | }) 12 | await common.init(client) 13 | var resp = await common.getUser(client, uuid); 14 | client.quit() 15 | return resp; 16 | } -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resolver/Query/mysql_getUser.js: -------------------------------------------------------------------------------- 1 | var common = require('../Common/mysql') 2 | const Client = require('serverless-mysql') 3 | exports.func = async (_, { uuid }) => { 4 | var client = Client({ 5 | config: { 6 | host: process.env.MYSQL_HOST, 7 | database: process.env.DB_NAME, 8 | user: process.env.USERNAME, 9 | password: process.env.PASSWORD 10 | } 11 | }) 12 | await common.init(client) 13 | var resp = await common.getUser(client, uuid); 14 | client.quit() 15 | return resp; 16 | } -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resolver/Query/postgresql_getUser.js: -------------------------------------------------------------------------------- 1 | const { Client } = require('pg') 2 | var common = require('../Common/postgresql') 3 | exports.func = async (_, { uuid }) => { 4 | var client = new Client({ 5 | host: process.env.POSTGRESQL_HOST, 6 | port: process.env.POSTGRESQL_PORT, 7 | database: process.env.DB_NAME, 8 | user: process.env.USERNAME, 9 | password: process.env.PASSWORD 10 | }) 11 | client.connect() 12 | await common.init(client) 13 | var resp = await common.getUser(client, uuid); 14 | client.end() 15 | return resp; 16 | } -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/AuroraRDSCluster.yml: -------------------------------------------------------------------------------- 1 | Type: AWS::RDS::DBCluster 2 | Properties: 3 | MasterUsername: ${self:custom.USERNAME} 4 | MasterUserPassword: ${self:custom.PASSWORD} 5 | DBSubnetGroupName: 6 | Ref: ServerlessSubnetGroup 7 | Engine: aurora 8 | EngineVersion: "5.6" 9 | DatabaseName: ${self:custom.DB_NAME} 10 | BackupRetentionPeriod: 3 11 | DBClusterParameterGroupName: 12 | Ref: AuroraRDSClusterParameter 13 | VpcSecurityGroupIds: 14 | - !Ref 'ServerlessSecurityGroup' -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/AuroraRDSClusterParameter.yml: -------------------------------------------------------------------------------- 1 | Type: AWS::RDS::DBClusterParameterGroup 2 | Properties: 3 | Description: Parameter group for the Serverless Aurora RDS DB. 4 | Family: aurora5.6 5 | Parameters: 6 | character_set_database: "utf32" -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/AuroraRDSInstance.yml: -------------------------------------------------------------------------------- 1 | DependsOn: ServerlessVPCGA 2 | Type: AWS::RDS::DBInstance 3 | Properties: 4 | DBInstanceClass: db.t2.small 5 | DBSubnetGroupName: 6 | Ref: ServerlessSubnetGroup 7 | Engine: aurora 8 | EngineVersion: "5.6" 9 | PubliclyAccessible: true 10 | DBParameterGroupName: 11 | Ref: AuroraRDSInstanceParameter 12 | DBClusterIdentifier: 13 | Ref: AuroraRDSCluster -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/AuroraRDSInstanceParameter.yml: -------------------------------------------------------------------------------- 1 | Type: AWS::RDS::DBParameterGroup 2 | Properties: 3 | Description: Parameter group for the Serverless Aurora RDS DB. 4 | Family: aurora5.6 5 | Parameters: 6 | sql_mode: IGNORE_SPACE 7 | max_connections: 100 8 | wait_timeout: 900 9 | interactive_timeout: 900 -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/LambdaRole.yml: -------------------------------------------------------------------------------- 1 | Type: AWS::IAM::Role 2 | Properties: 3 | AssumeRolePolicyDocument: 4 | Statement: 5 | - Effect: Allow 6 | Action: sts:AssumeRole 7 | Principal: 8 | Service: lambda.amazonaws.com 9 | Version: '2012-10-17' 10 | Policies: 11 | - PolicyName: CanLog 12 | PolicyDocument: 13 | Version: '2012-10-17' 14 | Statement: 15 | - Effect: Allow 16 | Action: 17 | - logs:CreateLogStream 18 | - logs:CreateLogGroup 19 | - logs:PutLogEvents 20 | Resource: arn:aws:logs:*:*:* -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/MySqlRDSInstance.yml: -------------------------------------------------------------------------------- 1 | DependsOn: ServerlessVPCGA 2 | Type: AWS::RDS::DBInstance 3 | Properties: 4 | MasterUsername: ${self:custom.USERNAME} 5 | MasterUserPassword: ${self:custom.PASSWORD} 6 | AllocatedStorage: 20 7 | DBName: ${self:custom.DB_NAME} 8 | DBInstanceClass: db.t2.micro 9 | VPCSecurityGroups: 10 | - !GetAtt ServerlessSecurityGroup.GroupId 11 | DBSubnetGroupName: 12 | Ref: ServerlessSubnetGroup 13 | Engine: mysql 14 | EngineVersion: "5.6.41" 15 | PubliclyAccessible: true -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/PostgreSqlRDSInstance.yml: -------------------------------------------------------------------------------- 1 | DependsOn: ServerlessVPCGA 2 | Type: AWS::RDS::DBInstance 3 | Properties: 4 | MasterUsername: ${self:custom.USERNAME} 5 | MasterUserPassword: ${self:custom.PASSWORD} 6 | AllocatedStorage: 20 7 | DBName: ${self:custom.DB_NAME} 8 | DBInstanceClass: db.t2.micro 9 | VPCSecurityGroups: 10 | - !GetAtt ServerlessSecurityGroup.GroupId 11 | DBSubnetGroupName: 12 | Ref: ServerlessSubnetGroup 13 | Engine: postgres 14 | PubliclyAccessible: true -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/RoutePublic.yml: -------------------------------------------------------------------------------- 1 | Type: AWS::EC2::Route 2 | Properties: 3 | DestinationCidrBlock: 0.0.0.0/0 4 | GatewayId: 5 | Ref: ServerlessInternetGateway 6 | RouteTableId: 7 | Ref: RouteTablePublic -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/RouteTableAssociationSubnetA.yml: -------------------------------------------------------------------------------- 1 | Type: AWS::EC2::SubnetRouteTableAssociation 2 | Properties: 3 | RouteTableId: 4 | Ref: RouteTablePublic 5 | SubnetId: 6 | Ref: ServerlessSubnetA -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/RouteTableAssociationSubnetB.yml: -------------------------------------------------------------------------------- 1 | Type: AWS::EC2::SubnetRouteTableAssociation 2 | Properties: 3 | RouteTableId: 4 | Ref: RouteTablePublic 5 | SubnetId: 6 | Ref: ServerlessSubnetB -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/RouteTableAssociationSubnetC.yml: -------------------------------------------------------------------------------- 1 | Type: AWS::EC2::SubnetRouteTableAssociation 2 | Properties: 3 | RouteTableId: 4 | Ref: RouteTablePublic 5 | SubnetId: 6 | Ref: ServerlessSubnetC -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/RouteTablePublic.yml: -------------------------------------------------------------------------------- 1 | Type: AWS::EC2::RouteTable 2 | Properties: 3 | VpcId: 4 | Ref: ServerlessVPC 5 | Tags: 6 | - Key: Name 7 | Value: public-route -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/ServerlessInternetGateway.yml: -------------------------------------------------------------------------------- 1 | Type: AWS::EC2::InternetGateway 2 | Properties: 3 | Tags: 4 | - 5 | Key: "Name" 6 | Value: "ServerlessInternetGateway" -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/ServerlessSecurityGroup.yml: -------------------------------------------------------------------------------- 1 | DependsOn: ServerlessVPC 2 | Type: AWS::EC2::SecurityGroup 3 | Properties: 4 | GroupDescription: SecurityGroup for Serverless Functions 5 | VpcId: 6 | Ref: ServerlessVPC 7 | SecurityGroupIngress: 8 | - IpProtocol: tcp 9 | FromPort: '0' 10 | ToPort: '65535' 11 | CidrIp: "0.0.0.0/0" 12 | Tags: 13 | - 14 | Key: "Name" 15 | Value: "ServerlessSecurityGroup" -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/ServerlessSubnetA.yml: -------------------------------------------------------------------------------- 1 | DependsOn: ServerlessVPC 2 | Type: AWS::EC2::Subnet 3 | Properties: 4 | VpcId: 5 | Ref: ServerlessVPC 6 | AvailabilityZone: ${self:provider.region}a 7 | CidrBlock: ${self:custom.AURORA.VPC_CIDR}.0.0.0/24 8 | Tags: 9 | - 10 | Key: "Name" 11 | Value: "ServerlessSubnetA" -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/ServerlessSubnetB.yml: -------------------------------------------------------------------------------- 1 | DependsOn: ServerlessVPC 2 | Type: AWS::EC2::Subnet 3 | Properties: 4 | VpcId: 5 | Ref: ServerlessVPC 6 | AvailabilityZone: ${self:provider.region}b 7 | CidrBlock: ${self:custom.AURORA.VPC_CIDR}.0.1.0/24 8 | Tags: 9 | - 10 | Key: "Name" 11 | Value: "ServerlessSubnetB" -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/ServerlessSubnetC.yml: -------------------------------------------------------------------------------- 1 | DependsOn: ServerlessVPC 2 | Type: AWS::EC2::Subnet 3 | Properties: 4 | VpcId: 5 | Ref: ServerlessVPC 6 | AvailabilityZone: ${self:provider.region}c 7 | CidrBlock: ${self:custom.AURORA.VPC_CIDR}.0.2.0/24 8 | Tags: 9 | - 10 | Key: "Name" 11 | Value: "ServerlessSubnetC" -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/ServerlessSubnetGroup.yml: -------------------------------------------------------------------------------- 1 | Type: AWS::RDS::DBSubnetGroup 2 | Properties: 3 | DBSubnetGroupDescription: "RDS Subnet Group" 4 | SubnetIds: 5 | - Ref: ServerlessSubnetA 6 | - Ref: ServerlessSubnetB 7 | - Ref: ServerlessSubnetC 8 | Tags: 9 | - 10 | Key: "Name" 11 | Value: "ServerlessSubnetGroup" -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/ServerlessVPC.yml: -------------------------------------------------------------------------------- 1 | Type: AWS::EC2::VPC 2 | Properties: 3 | CidrBlock: ${self:custom.AURORA.VPC_CIDR}.0.0.0/16 4 | EnableDnsSupport: true 5 | EnableDnsHostnames: true 6 | InstanceTenancy: default 7 | Tags: 8 | - 9 | Key: "Name" 10 | Value: "ServerlessVPC" -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/resource/ServerlessVPCGA.yml: -------------------------------------------------------------------------------- 1 | Type: AWS::EC2::VPCGatewayAttachment 2 | Properties: 3 | VpcId: 4 | Ref: ServerlessVPC 5 | InternetGatewayId: 6 | Ref: ServerlessInternetGateway -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/schema.gql: -------------------------------------------------------------------------------- 1 | type User { 2 | UUID: String 3 | Name: String 4 | Posts: [Post] 5 | } 6 | 7 | type Post { 8 | UUID: String 9 | Text: String 10 | } 11 | 12 | input UserInput { 13 | Name: String 14 | Posts: [PostInput] 15 | } 16 | 17 | input PostInput{ 18 | Text: String 19 | } 20 | 21 | type Mutation { 22 | mysql_createUser(input: UserInput!): User 23 | postgresql_createUser(input: UserInput!): User 24 | aurora_createUser(input: UserInput!): User 25 | } 26 | 27 | type Query { 28 | mysql_getUser(uuid: String!): User 29 | postgresql_getUser(uuid: String!): User 30 | aurora_getUser(uuid: String!): User 31 | } 32 | 33 | schema { 34 | query: Query 35 | mutation: Mutation 36 | } -------------------------------------------------------------------------------- /aws-node-graphql-and-rds/secrets.json: -------------------------------------------------------------------------------- 1 | { 2 | "ApiName": "graphql-api-and-serverless", 3 | "DefaultRegion": "us-east-1" 4 | } -------------------------------------------------------------------------------- /aws-node-graphql-api-with-dynamodb/.gitignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless -------------------------------------------------------------------------------- /aws-node-graphql-api-with-dynamodb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-node-graphql-api-with-dynamodb", 3 | "version": "1.0.0", 4 | "description": "A single-module GraphQL endpoint with query and mutation functionality.", 5 | "main": "handler.js", 6 | "dependencies": { 7 | "aws-sdk": "^2.136.0", 8 | "eslint-plugin-react": "^7.4.0", 9 | "graphql": "^0.11.7" 10 | }, 11 | "devDependencies": {}, 12 | "scripts": { 13 | "test": "echo \"Error: no test specified\" && exit 1" 14 | }, 15 | "author": "", 16 | "license": "ISC" 17 | } 18 | -------------------------------------------------------------------------------- /aws-node-heroku-postgres/.gitignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless -------------------------------------------------------------------------------- /aws-node-heroku-postgres/index.js: -------------------------------------------------------------------------------- 1 | // index.js 2 | 'use strict'; 3 | 4 | const { app } = require('./handler'); 5 | 6 | app.listen(3000, () => { 7 | console.info(`Listening on port 3000.`); 8 | }); 9 | -------------------------------------------------------------------------------- /aws-node-heroku-postgres/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-lambda-and-heroku-postgres", 3 | "version": "1.0.0", 4 | "description": "Shows how to connect AWS Lambda to Heroku Postgres. Uses an api:release Heroku webhook and the Heroku API to handle automatic Heroku Postgres credential rotation.", 5 | "main": "handler.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "axios": "^0.18.0", 13 | "express": "^4.16.4", 14 | "pg": "^7.7.1", 15 | "pg-connection-string": "^2.0.0", 16 | "serverless-http": "^1.8.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-node-heroku-postgres/serverless.yml: -------------------------------------------------------------------------------- 1 | service: aws-lambda-and-heroku-postgres # NOTE: update this with your service name 2 | 3 | provider: 4 | name: aws 5 | runtime: nodejs8.10 6 | stage: dev 7 | 8 | functions: 9 | hello: 10 | handler: handler.hello 11 | events: 12 | - http: GET hello 13 | - http: POST onrelease -------------------------------------------------------------------------------- /aws-node-iot-event/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-iot-event/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports.log = (event, context, callback) => { 4 | console.log(event); 5 | callback(null, {}); 6 | }; 7 | -------------------------------------------------------------------------------- /aws-node-iot-event/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-iot-event", 3 | "version": "1.0.0", 4 | "description": "Example on how to setup a AWS IoT Rule to send events to a Lambda function", 5 | "author": "", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-node-iot-event/serverless.yml: -------------------------------------------------------------------------------- 1 | service: aws-node-iot-event 2 | 3 | frameworkVersion: ">=1.5.0 <2.0.0" 4 | 5 | provider: 6 | name: aws 7 | runtime: nodejs8.10 8 | 9 | functions: 10 | log: 11 | handler: handler.log 12 | events: 13 | - iot: 14 | sql: "SELECT * FROM 'mybutton'" 15 | -------------------------------------------------------------------------------- /aws-node-mongodb-atlas/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localstack/serverless-examples/c4874f3cb38d67d64f90cc2d444941c55d8064b9/aws-node-mongodb-atlas/.gitignore -------------------------------------------------------------------------------- /aws-node-mongodb-atlas/README.md: -------------------------------------------------------------------------------- 1 | 12 | # aws-node-mongodb-atlas 13 | 14 | An example app, created in this [blog post](https://mattwelke.com/2019/02/18/free-tier-serverless-mongodb-with-aws-lambda-and-mongodb-atlas.html), showing how to connect AWS Lambda to MongoDB Atlas, which must be configured with a user with read/write privileges and an IP whitelist to allow Lambda to connect to it. See blog post for detailed walkthrough setting up MongoDB Atlas. 15 | -------------------------------------------------------------------------------- /aws-node-mongodb-atlas/index.js: -------------------------------------------------------------------------------- 1 | // index.js 2 | 'use strict'; 3 | 4 | const { app } = require('./handler'); 5 | 6 | app.listen(3000, () => { 7 | console.info(`Listening on port 3000.`); 8 | }); 9 | -------------------------------------------------------------------------------- /aws-node-mongodb-atlas/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-lambda-and-mongodb-atlas", 3 | "version": "1.0.0", 4 | "description": "Shows how to connect AWS Lambda to MongoDB Atlas.", 5 | "main": "handler.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "express": "^4.16.4", 14 | "faker": "^4.1.0", 15 | "mongodb": "^3.1.13", 16 | "serverless-http": "^1.9.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-node-mongodb-atlas/serverless.yml: -------------------------------------------------------------------------------- 1 | service: my-service # NOTE: update this with your service name 2 | 3 | provider: 4 | name: aws 5 | runtime: nodejs8.10 6 | 7 | functions: 8 | hello: 9 | handler: handler.hello 10 | events: 11 | - http: GET hello -------------------------------------------------------------------------------- /aws-node-oauth-dropbox-api/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /aws-node-oauth-dropbox-api/config/default.yml: -------------------------------------------------------------------------------- 1 | STAGE: 'default' 2 | HOME_URL: 'http://localhost:9999/' 3 | CLIENT_ID : 'xxxxxx' ##Change with your Dropbox Client Id 4 | CLIENT_SECRET : 'xxxxxx' ##Change with your Dropbox Client Secret 5 | CALLBACK_URL : 'http://localhost:9999/dropbox/callback' -------------------------------------------------------------------------------- /aws-node-oauth-dropbox-api/config/default_test.yml: -------------------------------------------------------------------------------- 1 | URL : 'http://localhost:9999/dropbox' 2 | EMAIL : 'xyzxyz@xyz.xyz' 3 | EMAIL_INPUT_BOX : 'input[name="login_email"]' 4 | PASSWORD : 'xyz@123' 5 | PASSWORD_INPUT_BOX : 'input[name="login_password"]' 6 | SUBMIT : '.login-button' 7 | ALLOW : ".button-primary" -------------------------------------------------------------------------------- /aws-node-oauth-dropbox-api/config/stage.yml: -------------------------------------------------------------------------------- 1 | STAGE: 'default' 2 | HOME_URL: 'https://xxxxxx.amazonaws.com/stage/dropbox' ##change with your lamba url 3 | CLIENT_ID : 'xxxxxx' ##Change with your Dropbox Client Id 4 | CLIENT_SECRET : 'xxxxxx' ##Change with your Dropbox Client Secret 5 | CALLBACK_URL : 'https://xxxxxx.amazonaws.com/stage/dropbox/callback' ##change with your lamba url -------------------------------------------------------------------------------- /aws-node-oauth-dropbox-api/config/stage_test.yml: -------------------------------------------------------------------------------- 1 | URL : 'https://xxxxxx.ap-south-1.amazonaws.com/stage/dropbox/' ##change with your lambda url 2 | EMAIL : 'xxxxxyz@xxxx.xyz' #change with your email id 3 | EMAIL_INPUT_BOX : 'input[name="login_email"]' 4 | PASSWORD : 'xxxx@123' #change with your password 5 | PASSWORD_INPUT_BOX : 'input[name="login_password"]' 6 | SUBMIT : '.login-button' 7 | ALLOW : ".button-primary" -------------------------------------------------------------------------------- /aws-node-puppeteer/.gitignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless -------------------------------------------------------------------------------- /aws-node-puppeteer/chrome-script.js: -------------------------------------------------------------------------------- 1 | const launchChrome = require('@serverless-chrome/lambda'); 2 | const request = require('superagent'); 3 | 4 | module.exports.getChrome = async () => { 5 | const chrome = await launchChrome(); 6 | 7 | const response = await request 8 | .get(`${chrome.url}/json/version`) 9 | .set('Content-Type', 'application/json'); 10 | 11 | const endpoint = response.body.webSocketDebuggerUrl; 12 | 13 | return { 14 | endpoint, 15 | instance: chrome, 16 | }; 17 | }; 18 | -------------------------------------------------------------------------------- /aws-node-puppeteer/handler.js: -------------------------------------------------------------------------------- 1 | const puppeteer = require('puppeteer'); 2 | const { getChrome } = require('./chrome-script'); 3 | 4 | module.exports.hello = async (event) => { 5 | const { url } = event.queryStringParameters; 6 | const chrome = await getChrome(); 7 | const browser = await puppeteer.connect({ 8 | browserWSEndpoint: chrome.endpoint, 9 | }); 10 | const page = await browser.newPage(); 11 | await page.goto(url, { waitUntil: 'networkidle0' }); 12 | const content = await page.evaluate(() => document.body.innerHTML); 13 | return { 14 | statusCode: 200, 15 | body: JSON.stringify({ 16 | content, 17 | }), 18 | }; 19 | }; 20 | -------------------------------------------------------------------------------- /aws-node-puppeteer/images/aws_limits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localstack/serverless-examples/c4874f3cb38d67d64f90cc2d444941c55d8064b9/aws-node-puppeteer/images/aws_limits.png -------------------------------------------------------------------------------- /aws-node-puppeteer/serverless.yml: -------------------------------------------------------------------------------- 1 | service: scrapper-lambda 2 | provider: 3 | name: aws 4 | profile: 5 | runtime: nodejs12.x 6 | 7 | plugins: 8 | - serverless-offline 9 | - serverless-plugin-chrome 10 | 11 | package: 12 | exclude: 13 | - node_modules/puppeteer/.local-chromium/** 14 | 15 | functions: 16 | hello: 17 | handler: handler.hello 18 | memorySize: 1536MB 19 | timeout: 30 20 | events: 21 | - http: 22 | path: / 23 | method: get 24 | -------------------------------------------------------------------------------- /aws-node-recursive-function/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-recursive-function/event.json: -------------------------------------------------------------------------------- 1 | { 2 | "numberOfCalls": 5 3 | } -------------------------------------------------------------------------------- /aws-node-recursive-function/serverless.yml: -------------------------------------------------------------------------------- 1 | 2 | service: recursive-invocation-example 3 | 4 | custom: 5 | functionARN: yourFunctionARN 6 | 7 | provider: 8 | name: aws 9 | runtime: nodejs8.10 10 | # iamRoleStatements: 11 | # - Effect: "Allow" 12 | # Action: 13 | # - "lambda:InvokeFunction" 14 | # Resource: ${self:custom.functionARN} 15 | 16 | functions: 17 | recursiveExample: 18 | handler: handler.recursiveLambda -------------------------------------------------------------------------------- /aws-node-rekognition-analysis-s3-image/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-rekognition-analysis-s3-image/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-node-rekognition-analysis-s3-image", 3 | "description": "Analyse an Image from an S3 Bucket with Amazon Rekognition", 4 | "version": "1.0.0", 5 | "author": "lynnaloo", 6 | "license": "MIT", 7 | "dependencies": { 8 | "aws-sdk": "^2.32.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aws-node-rekognition-analysis-s3-image/post.json: -------------------------------------------------------------------------------- 1 | { 2 | "body": { 3 | "bucket": "mycatphotos", 4 | "imageName": "cat.jpg" 5 | } 6 | } -------------------------------------------------------------------------------- /aws-node-rekognition-analysis-s3-image/serverless.yml: -------------------------------------------------------------------------------- 1 | service: rekognition-analysis-s3-image 2 | 3 | frameworkVersion: ">=1.10.0" 4 | 5 | provider: 6 | name: aws 7 | runtime: nodejs6.10 8 | memorySize: 512 9 | timeout: 10 10 | stage: dev 11 | region: us-east-1 12 | 13 | iamRoleStatements: 14 | - Effect: Allow 15 | Action: 16 | - s3:* 17 | Resource: "*" 18 | - Effect: "Allow" 19 | Action: 20 | - "rekognition:*" 21 | Resource: "*" 22 | 23 | functions: 24 | imageAnalysis: 25 | handler: handler.imageAnalysis 26 | events: 27 | - http: 28 | path: analysis 29 | method: post 30 | -------------------------------------------------------------------------------- /aws-node-rest-api-mongodb/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | node_modules 3 | -------------------------------------------------------------------------------- /aws-node-rest-api-mongodb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-node-restapi-mongodb", 3 | "version": "1.0.0", 4 | "description": "Serverless REST API with MongoDB using Mongoose and Bluebird", 5 | "main": "handler.js", 6 | "dependencies": { 7 | "bluebird": "^3.5.0", 8 | "mongoose": "^4.9.6", 9 | "validator": "^7.0.0" 10 | }, 11 | "author": "Quentin Homareau ", 12 | "license": "MIT" 13 | } 14 | -------------------------------------------------------------------------------- /aws-node-rest-api-with-dynamodb-and-offline/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | node_modules 3 | -------------------------------------------------------------------------------- /aws-node-rest-api-with-dynamodb-and-offline/offline/migrations/todos.json: -------------------------------------------------------------------------------- 1 | { 2 | "Table": { 3 | "TableName": "serverless-rest-api-with-dynamodb-dev", 4 | "KeySchema": [ 5 | { 6 | "AttributeName": "id", 7 | "KeyType": "HASH" 8 | } 9 | ], 10 | "AttributeDefinitions": [ 11 | { 12 | "AttributeName": "id", 13 | "AttributeType": "S" 14 | } 15 | ], 16 | "ProvisionedThroughput": { 17 | "ReadCapacityUnits": 1, 18 | "WriteCapacityUnits": 1 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aws-node-rest-api-with-dynamodb-and-offline/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-rest-api-offline", 3 | "version": "1.0.0", 4 | "description": "Serverless REST API with DynamoDB and offline support", 5 | "repository": "", 6 | "author": "Christoph Gysin ", 7 | "license": "MIT", 8 | "dependencies": { 9 | "uuid": "^2.0.3" 10 | }, 11 | "devDependencies": { 12 | "aws-sdk": "^2.12.0", 13 | "serverless-dynamodb-local": "^0.2.18", 14 | "serverless-offline": "^3.8.3" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aws-node-rest-api-with-dynamodb-and-offline/todos/dynamodb.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const AWS = require('aws-sdk'); // eslint-disable-line import/no-extraneous-dependencies 4 | 5 | let options = {}; 6 | 7 | // connect to local DB if running offline 8 | if (process.env.IS_OFFLINE) { 9 | options = { 10 | region: 'localhost', 11 | endpoint: 'http://localhost:8000', 12 | }; 13 | } 14 | 15 | const client = new AWS.DynamoDB.DocumentClient(options); 16 | 17 | module.exports = client; 18 | -------------------------------------------------------------------------------- /aws-node-rest-api-with-dynamodb/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-rest-api-with-dynamodb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-rest-with-dynamodb", 3 | "version": "1.0.0", 4 | "description": "Serverless CRUD service exposing a REST HTTP interface", 5 | "author": "", 6 | "license": "MIT", 7 | "dependencies": { 8 | "uuid": "^2.0.3" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aws-node-s3-file-replicator/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-s3-file-replicator/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-fetch-file-and-store-in-s3", 3 | "description": "Fetch an image from remote source (URL) and then upload the image to a S3 bucket.", 4 | "version": "1.0.0", 5 | "author": "Bozhao Yu", 6 | "license": "MIT", 7 | "dependencies": {}, 8 | "devDependencies": { 9 | "aws-sdk": "^2.467.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /aws-node-scheduled-cron/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-scheduled-cron/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports.run = (event, context) => { 4 | const time = new Date(); 5 | console.log(`Your cron function "${context.functionName}" ran at ${time}`); 6 | }; 7 | -------------------------------------------------------------------------------- /aws-node-scheduled-cron/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-scheduled-cron", 3 | "version": "1.0.0", 4 | "description": "Example of creating a function that runs as a cron job using the serverless `schedule` event", 5 | "author": "", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-node-scheduled-cron/serverless.yml: -------------------------------------------------------------------------------- 1 | service: scheduled-cron-example 2 | 3 | provider: 4 | name: aws 5 | runtime: nodejs12.x 6 | 7 | functions: 8 | cron: 9 | handler: handler.run 10 | events: 11 | # Invoke Lambda function every minute 12 | - schedule: rate(1 minute) 13 | secondCron: 14 | handler: handler.run 15 | events: 16 | # Invoke Lambda function every 2nd minute from Mon-Fri 17 | - schedule: cron(0/2 * ? * MON-FRI *) 18 | -------------------------------------------------------------------------------- /aws-node-scheduled-weather/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-scheduled-weather/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const getForecast = require('./lib/forecast'); 4 | const sendEmail = require('./lib/email'); 5 | 6 | const latitude = process.env.LATITUDE; 7 | const longitude = process.env.LONGITUDE; 8 | const emailRecpient = process.env.RECIPIENT; 9 | const emailSubject = 'Current Weather'; 10 | 11 | module.exports.run = (event, context, callback) => { 12 | getForecast(latitude, longitude) 13 | .then((forecast) => { // eslint-disable-line arrow-body-style 14 | return sendEmail(emailRecpient, emailSubject, forecast); 15 | }) 16 | .then(() => { 17 | callback(null, { success: true }); 18 | }) 19 | .catch((error) => { 20 | callback(error, { success: false }); 21 | }); 22 | }; 23 | -------------------------------------------------------------------------------- /aws-node-scheduled-weather/lib/email.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Postmark = require('postmark'); 4 | 5 | const client = new Postmark.Client(process.env.POSTMARK_API_KEY); 6 | 7 | module.exports = (to, subject, body) => { 8 | const options = { 9 | From: process.env.POSTMARK_SENDER, 10 | To: to, 11 | Subject: subject, 12 | TextBody: JSON.stringify(body), 13 | }; 14 | 15 | return new Promise((resolve, reject) => { 16 | client.sendEmail(options, (error, result) => { 17 | if (error) { 18 | reject(error); 19 | } else { 20 | resolve(result); 21 | } 22 | }); 23 | }); 24 | }; 25 | -------------------------------------------------------------------------------- /aws-node-scheduled-weather/lib/forecast.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const DarkSky = require('forecast.io'); 4 | 5 | const client = new DarkSky({ 6 | APIKey: process.env.DARK_SKY_API_KEY, 7 | }); 8 | 9 | module.exports = (latitude, longitude) => { 10 | const options = { 11 | exclude: 'minutely,hourly,daily,flags,alerts', 12 | }; 13 | 14 | return new Promise((resolve, reject) => { 15 | client.get(latitude, longitude, options, (error, data) => { 16 | if (error) { 17 | reject(error); 18 | } else { 19 | resolve(data); 20 | } 21 | }); 22 | }); 23 | }; 24 | -------------------------------------------------------------------------------- /aws-node-scheduled-weather/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-scheduled-weather", 3 | "version": "1.0.0", 4 | "description": "Example of creating a function that runs as a cron job using the serverless `schedule` event through pulling weather and sending an email daily.", 5 | "author": "Tom Milewski ", 6 | "license": "MIT", 7 | "dependencies": { 8 | "forecast.io": "0.0.11", 9 | "postmark": "^1.3.1" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /aws-node-scheduled-weather/serverless.yml: -------------------------------------------------------------------------------- 1 | service: scheduled-weather-example 2 | frameworkVersion: ">=1.1.0 <2.0.0" 3 | 4 | provider: 5 | name: aws 6 | runtime: nodejs8.10 7 | environment: 8 | RECIPIENT: tom@carrotcreative.com 9 | DARK_SKY_API_KEY: abc123 10 | POSTMARK_API_KEY: abc123 11 | POSTMARK_SENDER: devops@carrotcreative.com 12 | LATITUDE: 40.702637 13 | LONGITUDE: -73.989406 14 | 15 | functions: 16 | weather: 17 | handler: handler.run 18 | memorySize: 128 19 | timeout: 5 20 | events: 21 | # 10am UTC, daily 22 | - schedule: cron(0 10 * * ? *) 23 | -------------------------------------------------------------------------------- /aws-node-serve-dynamic-html-via-http-endpoint/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-serve-dynamic-html-via-http-endpoint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-serve-dynamic-html-via-http-endpoint", 3 | "version": "1.0.0", 4 | "description": "Hookup an AWS API Gateway endpoint to a Lambda function to render HTML on a `GET` request", 5 | "author": "", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-node-serve-dynamic-html-via-http-endpoint/serverless.yml: -------------------------------------------------------------------------------- 1 | # Serving HTML through API Gateway for AWS Lambda 2 | service: serve-dynamic-html-via-http-endpoint 3 | 4 | frameworkVersion: ">=1.1.0 <2.0.0" 5 | 6 | provider: 7 | name: aws 8 | runtime: nodejs8.10 9 | 10 | functions: 11 | landingPage: 12 | handler: handler.landingPage 13 | events: 14 | - http: 15 | method: get 16 | path: landing-page 17 | -------------------------------------------------------------------------------- /aws-node-serverless-gong/node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localstack/serverless-examples/c4874f3cb38d67d64f90cc2d444941c55d8064b9/aws-node-serverless-gong/node -------------------------------------------------------------------------------- /aws-node-serverless-gong/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-node-serverless-gong", 3 | "version": "1.0.0", 4 | "description": "A simple serverless gong using GitHub webhooks and a Slack app", 5 | "author": "Anna Spysz", 6 | "license": "MIT", 7 | "dependencies": { 8 | "aws-sdk": "~2", 9 | "slack-node": "0.1.8" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /aws-node-serverless-gong/serverless-examples@0.0.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localstack/serverless-examples/c4874f3cb38d67d64f90cc2d444941c55d8064b9/aws-node-serverless-gong/serverless-examples@0.0.0 -------------------------------------------------------------------------------- /aws-node-ses-receive-email-body/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless -------------------------------------------------------------------------------- /aws-node-ses-receive-email-body/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-node-ses-receive-email-body", 3 | "description": "Receive an email, store in S3 bucket, trigger a lambda function.", 4 | "version": "1.0.0", 5 | "author": "Andreas Heissenberger ", 6 | "license": "MIT", 7 | "dependencies": { 8 | "mailparser": "^2.3.4" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aws-node-ses-receive-email-header/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless -------------------------------------------------------------------------------- /aws-node-ses-receive-email-header/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-node-ses-receive-email-header", 3 | "description": "Receive an email, trigger a lambda function to process header.", 4 | "version": "1.0.0", 5 | "author": "Andreas Heissenberger ", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-node-shared-gateway/ci-decomission.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Demolishing your awesome stacks..." 4 | cd products 5 | serverless remove 6 | 7 | cd .. 8 | cd transactions 9 | serverless remove 10 | 11 | cd .. 12 | cd users 13 | serverless remove 14 | 15 | cd .. 16 | cd gateway 17 | serverless remove 18 | 19 | echo "Demolishing complete :)" 20 | read -------------------------------------------------------------------------------- /aws-node-shared-gateway/ci-deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd gateway 4 | serverless deploy 5 | sleep 5s 6 | 7 | cd .. 8 | cd products 9 | serverless deploy 10 | sleep 5s 11 | 12 | cd .. 13 | cd transactions 14 | serverless deploy 15 | sleep 5s 16 | 17 | cd .. 18 | cd users 19 | serverless deploy 20 | sleep 5s 21 | 22 | echo "Press any key to continue" 23 | read -------------------------------------------------------------------------------- /aws-node-shared-gateway/gateway/.gitignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless -------------------------------------------------------------------------------- /aws-node-shared-gateway/gateway/serverless.yml: -------------------------------------------------------------------------------- 1 | service: shared-gateway 2 | provider: 3 | name: aws 4 | runtime: nodejs8.10 5 | region: ap-southeast-1 6 | resources: 7 | Resources: 8 | SharedGW: 9 | Type: AWS::ApiGateway::RestApi 10 | Properties: 11 | Name: SharedGW 12 | Outputs: 13 | apiGatewayRestApiId: 14 | Value: 15 | Ref: SharedGW 16 | Export: 17 | Name: SharedGW-restApiId 18 | apiGatewayRestApiRootResourceId: 19 | Value: 20 | Fn::GetAtt: 21 | - SharedGW 22 | - RootResourceId 23 | Export: 24 | Name: SharedGW-rootResourceId 25 | -------------------------------------------------------------------------------- /aws-node-shared-gateway/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shared-aws-api-gateway-nodejs", 3 | "version": "1.0.0", 4 | "description": "A sample of implementing shared API gateway with multiple Node Lambdas.", 5 | "main": "handler.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /aws-node-shared-gateway/products/.gitignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless -------------------------------------------------------------------------------- /aws-node-shared-gateway/products/handler.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | module.exports.getProducts = async event => { 4 | return { 5 | statusCode: 200, 6 | body: JSON.stringify([ 7 | { 8 | id: "20379435-7c7b-4bdd-8d0c-3f3136979c29", 9 | name: "Foo 1", 10 | price: 22 11 | }, 12 | { 13 | id: "f7c26612-63ff-4064-89c8-9a316ba043a3", 14 | name: "Foo 2", 15 | price: 23 16 | }, 17 | { 18 | id: "c04f63f0-b2ad-4526-a187-b6ac8adcc648", 19 | name: "Foo 3", 20 | price: 24 21 | } 22 | ]) 23 | }; 24 | }; 25 | -------------------------------------------------------------------------------- /aws-node-shared-gateway/products/serverless.yml: -------------------------------------------------------------------------------- 1 | service: eshop-products 2 | provider: 3 | name: aws 4 | runtime: nodejs8.10 5 | region: ap-southeast-1 6 | apiGateway: 7 | restApiId: 8 | "Fn::ImportValue": SharedGW-restApiId 9 | restApiRootResourceId: 10 | "Fn::ImportValue": SharedGW-rootResourceId 11 | functions: 12 | get-products: 13 | handler: handler.getProducts 14 | events: 15 | - http: 16 | path: products/list 17 | method: get 18 | -------------------------------------------------------------------------------- /aws-node-shared-gateway/transactions/.gitignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless -------------------------------------------------------------------------------- /aws-node-shared-gateway/transactions/handler.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | module.exports.getTransactions = async event => { 4 | return { 5 | statusCode: 200, 6 | body: JSON.stringify([ 7 | { 8 | id: "72cd348d-3a9a-4173-a424-34908c43580a", 9 | productName: "Foo 1", 10 | price: 50, 11 | customerName: "Allan" 12 | }, 13 | { 14 | id: "94df26f3-7acc-4b3f-a698-a28707f90f04", 15 | productName: "Foo 2", 16 | price: 40, 17 | customerName: "Laura" 18 | }, 19 | { 20 | id: "5931c2f2-7345-4820-93ce-0cb5907a361b", 21 | name: "Foo 3", 22 | price: 21, 23 | customerName: "Tom" 24 | } 25 | ]) 26 | }; 27 | }; 28 | -------------------------------------------------------------------------------- /aws-node-shared-gateway/transactions/serverless.yml: -------------------------------------------------------------------------------- 1 | service: eshop-transactions 2 | provider: 3 | name: aws 4 | runtime: nodejs8.10 5 | region: ap-southeast-1 6 | apiGateway: 7 | restApiId: 8 | "Fn::ImportValue": SharedGW-restApiId 9 | restApiRootResourceId: 10 | "Fn::ImportValue": SharedGW-rootResourceId 11 | functions: 12 | get-transactions: 13 | handler: handler.getTransactions 14 | events: 15 | - http: 16 | path: transactions/list 17 | method: get 18 | -------------------------------------------------------------------------------- /aws-node-shared-gateway/users/.gitignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless -------------------------------------------------------------------------------- /aws-node-shared-gateway/users/handler.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | module.exports.getUsers = async event => { 4 | return { 5 | statusCode: 200, 6 | body: JSON.stringify([ 7 | { 8 | id: "09d21d59-c138-4f70-ae82-3552148d3d43", 9 | name: "Jimbo" 10 | }, 11 | { 12 | id: "2f8fb730-5d09-4493-aea5-46b3e3f8b08a", 13 | name: "Dumbo" 14 | }, 15 | { 16 | id: "03d2690f-6d01-4cf1-b947-a8cc0133cc9f", 17 | name: "Rambo" 18 | } 19 | ]) 20 | }; 21 | }; 22 | -------------------------------------------------------------------------------- /aws-node-shared-gateway/users/serverless.yml: -------------------------------------------------------------------------------- 1 | service: eshop-users 2 | provider: 3 | name: aws 4 | runtime: nodejs8.10 5 | region: ap-southeast-1 6 | apiGateway: 7 | restApiId: 8 | "Fn::ImportValue": SharedGW-restApiId 9 | restApiRootResourceId: 10 | "Fn::ImportValue": SharedGW-rootResourceId 11 | functions: 12 | get-users: 13 | handler: handler.getUsers 14 | events: 15 | - http: 16 | path: users/list 17 | method: get 18 | -------------------------------------------------------------------------------- /aws-node-signed-uploads/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "targets": { 7 | "node": "8.10" 8 | }, 9 | "modules": false, 10 | "loose": true 11 | } 12 | ] 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /aws-node-signed-uploads/.eslintrc: -------------------------------------------------------------------------------- 1 | --- 2 | root: true 3 | extends: 4 | - airbnb-base 5 | env: 6 | node: true 7 | -------------------------------------------------------------------------------- /aws-node-signed-uploads/.gitignore: -------------------------------------------------------------------------------- 1 | coverage 2 | .serverless 3 | .webpack 4 | node_modules 5 | *.log 6 | config.json 7 | -------------------------------------------------------------------------------- /aws-node-signed-uploads/webpack.config.js: -------------------------------------------------------------------------------- 1 | const slsw = require('serverless-webpack'); 2 | const path = require('path'); 3 | 4 | module.exports = { 5 | entry: slsw.lib.entries, 6 | target: 'node', 7 | externals: [{ 'aws-sdk': true }], 8 | module: { 9 | rules: [ 10 | { 11 | test: /\.js$/, 12 | include: __dirname, 13 | exclude: /node_modules/, 14 | use: [{ loader: 'babel-loader' }], 15 | }, 16 | ], 17 | }, 18 | output: { 19 | libraryTarget: 'commonjs', 20 | path: path.join(__dirname, '.webpack'), 21 | filename: '[name].js', 22 | }, 23 | }; 24 | -------------------------------------------------------------------------------- /aws-node-simple-http-endpoint/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-simple-http-endpoint/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports.endpoint = (event, context, callback) => { 4 | const response = { 5 | statusCode: 200, 6 | body: JSON.stringify({ 7 | message: `Hello, the current time is ${new Date().toTimeString()}.`, 8 | }), 9 | }; 10 | 11 | callback(null, response); 12 | }; 13 | -------------------------------------------------------------------------------- /aws-node-simple-http-endpoint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-serve-simple-http-endpoint", 3 | "version": "1.0.0", 4 | "description": "Example demonstrates how to setup a simple HTTP GET endpoint", 5 | "author": "", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-node-simple-http-endpoint/serverless.yml: -------------------------------------------------------------------------------- 1 | service: serverless-simple-http-endpoint 2 | 3 | frameworkVersion: ">=1.1.0 <2.0.0" 4 | 5 | provider: 6 | name: aws 7 | runtime: nodejs8.10 8 | 9 | functions: 10 | currentTime: 11 | handler: handler.endpoint 12 | events: 13 | - http: 14 | path: ping 15 | method: get 16 | -------------------------------------------------------------------------------- /aws-node-simple-transcribe-s3/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | -------------------------------------------------------------------------------- /aws-node-simple-transcribe-s3/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-node-simple-transcribe-s3", 3 | "version": "1.0.0", 4 | "description": "Example demonstrates how to setup a lambda function to transcribe audio file", 5 | "author": "", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-node-single-page-app-via-cloudfront/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-single-page-app-via-cloudfront/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /aws-node-single-page-app-via-cloudfront/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-single-page-app-via-cloudfront", 3 | "version": "1.0.0", 4 | "description": "Demonstrating how to deploy a Single Page Application with Serverless", 5 | "repository": "", 6 | "author": "", 7 | "license": "MIT", 8 | "devDependencies": { 9 | "serverless-single-page-app-plugin": "file:./serverless-single-page-app-plugin" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /aws-node-single-page-app-via-cloudfront/serverless-single-page-app-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "serverless-single-page-app-plugin", 3 | "version": "1.0.0", 4 | "description": "A plugin to simplify deploying Single Page Application using S3 and CloudFront", 5 | "author": "", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-node-stripe-integration/.gitignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless 7 | 8 | # Config yaml (local.yaml) 9 | config/local.yaml 10 | -------------------------------------------------------------------------------- /aws-node-stripe-integration/config/default.yaml: -------------------------------------------------------------------------------- 1 | stripe: 2 | test_sk: 'sk_test_XXXXXXXXXXXXXXXXXXXXXXXX' 3 | live_sk: 'sk_live_XXXXXXXXXXXXXXXXXXXXXXXX' -------------------------------------------------------------------------------- /aws-node-stripe-integration/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-node-stripe-integration", 3 | "version": "1.0.0", 4 | "description": "This example for Stripe integration using AWS Lambda and API Gateway.", 5 | "main": "handler.js", 6 | "dependencies": { 7 | "config": "^1.24.0", 8 | "js-yaml": "^3.7.0", 9 | "stripe": "^4.14.0" 10 | }, 11 | "devDependencies": {}, 12 | "scripts": { 13 | "test": "echo \"Error: no test specified\" && exit 1" 14 | }, 15 | "author": "", 16 | "license": "ISC" 17 | } 18 | -------------------------------------------------------------------------------- /aws-node-telegram-echo-bot/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const request = require('request'); 4 | 5 | module.exports.webhook = (event, context, callback) => { 6 | const token = '[YOU TOKEN PLZ]'; 7 | const BASE_URL = `https://api.telegram.org/bot${token}/sendMessage`; 8 | 9 | const body = JSON.parse(event.body) 10 | const message = body.message 11 | const chatId = message.chat.id 12 | 13 | request.post(BASE_URL).form({ text: message.text, chat_id: chatId }); 14 | 15 | const response = { 16 | statusCode: 200, 17 | body: JSON.stringify({ 18 | input: event, 19 | }), 20 | }; 21 | 22 | return callback(null, response); 23 | 24 | }; 25 | 26 | -------------------------------------------------------------------------------- /aws-node-telegram-echo-bot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-node-line-echo-bot", 3 | "version": "1.0.0", 4 | "description": "This is a simple echo bot on Telegram", 5 | "main": "handler.js", 6 | "keywords": [ 7 | "aws", 8 | "nodejs", 9 | "telegram", 10 | "chatbot", 11 | "serverless" 12 | ], 13 | "dependencies": { 14 | "request": "^2.88.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aws-node-telegram-echo-bot/serverless.yml: -------------------------------------------------------------------------------- 1 | service: aws-node-telegram-echo-bot 2 | 3 | provider: 4 | name: aws 5 | runtime: nodejs8.10 6 | 7 | functions: 8 | webhook: 9 | handler: handler.webhook 10 | events: 11 | - http: 12 | path: webhook 13 | method: post 14 | -------------------------------------------------------------------------------- /aws-node-text-analysis-via-sns-post-processing/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-text-analysis-via-sns-post-processing/analyzeNote.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const sentiment = require('sentiment'); 4 | 5 | module.exports.analyzeNote = (event) => { 6 | const note = event.Records[0].Sns.Message; 7 | const result = sentiment(note); 8 | if (result.score > 2) { 9 | console.log(`Positive note - will be published: ${note}`); 10 | } else { 11 | console.log(`Negative note - won't be published: ${note}`); 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /aws-node-text-analysis-via-sns-post-processing/config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | awsAccountId: 'XXXXXXXXXXXX', 5 | }; 6 | -------------------------------------------------------------------------------- /aws-node-text-analysis-via-sns-post-processing/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-text-analysis-via-sns-post-processing", 3 | "version": "1.0.0", 4 | "description": "Example demonstrates how to setup a simple data processing pipeline", 5 | "author": "", 6 | "license": "MIT", 7 | "dependencies": { 8 | "sentiment": "^2.1.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aws-node-text-analysis-via-sns-post-processing/serverless.yml: -------------------------------------------------------------------------------- 1 | service: text-analysis-via-sns-post-processing 2 | 3 | frameworkVersion: ">=1.1.0 <2.0.0" 4 | 5 | provider: 6 | name: aws 7 | runtime: nodejs8.10 8 | region: us-east-1 9 | stage: dev 10 | iamRoleStatements: 11 | - Effect: "Allow" 12 | Resource: "*" 13 | Action: 14 | - "sns:*" 15 | 16 | functions: 17 | addNote: 18 | handler: addNote.addNote 19 | events: 20 | - http: 21 | path: notes 22 | method: post 23 | cors: true 24 | 25 | analyzeNote: 26 | handler: analyzeNote.analyzeNote 27 | events: 28 | - sns: analyzeNote 29 | -------------------------------------------------------------------------------- /aws-node-twilio-send-text-message/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /aws-node-twilio-send-text-message/.npmignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless 7 | -------------------------------------------------------------------------------- /aws-node-twilio-send-text-message/event.json: -------------------------------------------------------------------------------- 1 | { 2 | "body": { 3 | "to": "your-number-here", 4 | "message": "Welcome to Serverless ⊂◉‿◉つ", 5 | "image": "https://c1.staticflickr.com/3/2899/14341091933_1e92e62d12_b.jpg" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /aws-node-twilio-send-text-message/messenger.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | class Messenger { 4 | constructor(client) { 5 | this.client = client; 6 | } 7 | 8 | send(event) { 9 | // use twilio SDK to send text message 10 | const sms = { 11 | to: event.body.to, 12 | body: event.body.message || '', 13 | from: event.from, 14 | }; 15 | 16 | // add image to sms if supplied 17 | if (event.body.image) { 18 | sms.mediaUrl = event.body.image; 19 | } 20 | 21 | return this.client.messages.create(sms); 22 | } 23 | } 24 | 25 | module.exports = Messenger; 26 | -------------------------------------------------------------------------------- /aws-node-twilio-send-text-message/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-node-twilio-send-text-message", 3 | "version": "0.0.1", 4 | "description": "Send a text message via twilio from aws lambda. [See live demo](http://twilio-serverless-example.surge.sh)", 5 | "main": "handler.js", 6 | "scripts": { 7 | "test": "./node_modules/.bin/mocha *.test.js" 8 | }, 9 | "author": "David Wells", 10 | "license": "MIT", 11 | "dependencies": { 12 | "twilio": "^2.11.1" 13 | }, 14 | "devDependencies": { 15 | "chai": "^4.0.0", 16 | "mocha": "^3.4.2", 17 | "sinon": "^2.3.2" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /aws-node-twilio-send-text-message/serverless.yml: -------------------------------------------------------------------------------- 1 | service: aws-node-twilio 2 | 3 | provider: 4 | name: aws 5 | runtime: nodejs8.10 6 | environment: 7 | # replace these env variables with your twilio account values 8 | TWILIO_ACCOUNT_SID: YOUR-TWILIO-ACCOUNT-SID-HERE 9 | TWILIO_AUTH_TOKEN: YOUR-TWILIO-AUTH-TOKEN-HERE 10 | TWILIO_PHONE_NUMBER: YOUR-TWILIO-PHONE-NUMBER-HERE 11 | 12 | package: 13 | exclude: 14 | - "*.test.js" 15 | - 'node_modules/**' 16 | - '!node_modules/twilio/**' 17 | - 'frontend/**' 18 | 19 | functions: 20 | sendText: 21 | handler: handler.sendText 22 | events: 23 | - http: 24 | path: api/sendText 25 | method: post 26 | integration: lambda 27 | cors: true 28 | -------------------------------------------------------------------------------- /aws-node-twitter-joke-bot/helpers/jokes.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | 3 | const options = { 4 | headers: { 5 | Accept: 'application/json', 6 | 'User-Agent': 'My Library (YOUR LIBRARY URL HERE)', 7 | }, 8 | }; 9 | 10 | const getDadJoke = () => new Promise((resolve, reject) => { 11 | fetch(process.env.JOKES_API_URL, options) 12 | .then(response => response.json()) 13 | .then(json => resolve(json)) 14 | .catch(error => reject(error)); 15 | }); 16 | 17 | module.exports = { 18 | getDadJoke, 19 | }; 20 | -------------------------------------------------------------------------------- /aws-node-twitter-joke-bot/helpers/twitter.js: -------------------------------------------------------------------------------- 1 | const Twitter = require('twitter'); 2 | 3 | const client = new Twitter({ 4 | consumer_key: process.env.TWITTER_CONSUMER_KEY, 5 | consumer_secret: process.env.TWITTER_CONSUMER_SECRET, 6 | access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY, 7 | access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET, 8 | }); 9 | 10 | const tweetJoke = joke => new Promise((resolve, reject) => { 11 | client.post('statuses/update', { status: joke }) 12 | .then(tweet => resolve(tweet)) 13 | .catch(error => reject(error)); 14 | }); 15 | 16 | module.exports = { 17 | tweetJoke, 18 | }; 19 | -------------------------------------------------------------------------------- /aws-node-twitter-joke-bot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "baddadjokesbot", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "handler.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/Fixy250185/baddadjokesbot.git" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "bugs": { 17 | "url": "https://github.com/Fixy250185/baddadjokesbot/issues" 18 | }, 19 | "homepage": "https://github.com/Fixy250185/baddadjokesbot#readme", 20 | "dependencies": { 21 | "node-fetch": "^2.2.1", 22 | "twitter": "^1.7.1" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /aws-node-twitter-joke-bot/serverless.yml: -------------------------------------------------------------------------------- 1 | service: baddadjokesbot 2 | 3 | provider: 4 | name: aws 5 | runtime: nodejs8.10 6 | stage: ${opt:stage, 'dev'} 7 | region: ${opt:region, 'eu-west-1'} 8 | 9 | custom: 10 | env: ${file(./${self:provider.stage}.env.json)} 11 | 12 | functions: 13 | bot: 14 | handler: handler.bot 15 | events: 16 | - schedule: rate(5 hours) 17 | environment: 18 | JOKES_API_URL: ${self:custom.env.JOKES_API_URL} 19 | TWITTER_CONSUMER_KEY: ${self:custom.env.TWITTER_CONSUMER_KEY} 20 | TWITTER_CONSUMER_SECRET: ${self:custom.env.TWITTER_CONSUMER_SECRET} 21 | TWITTER_ACCESS_TOKEN_KEY: ${self:custom.env.TWITTER_ACCESS_TOKEN_KEY} 22 | TWITTER_ACCESS_TOKEN_SECRET: ${self:custom.env.TWITTER_ACCESS_TOKEN_SECRET} 23 | -------------------------------------------------------------------------------- /aws-node-typescript-nest/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | /.build/ 3 | /.serverless/ 4 | /_warmup/ -------------------------------------------------------------------------------- /aws-node-typescript-nest/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /aws-node-typescript-nest/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "language": "ts", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src" 5 | } 6 | -------------------------------------------------------------------------------- /aws-node-typescript-nest/nodemon-debug.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["src"], 3 | "ext": "ts", 4 | "ignore": ["src/**/*.spec.ts"], 5 | "exec": "node --inspect-brk -r ts-node/register -r tsconfig-paths/register src/main.ts" 6 | } 7 | -------------------------------------------------------------------------------- /aws-node-typescript-nest/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["src"], 3 | "ext": "ts", 4 | "ignore": ["src/**/*.spec.ts"], 5 | "exec": "ts-node -r tsconfig-paths/register src/main.ts" 6 | } 7 | -------------------------------------------------------------------------------- /aws-node-typescript-nest/serverless.yml: -------------------------------------------------------------------------------- 1 | service: 2 | name: serverless-nest-example 3 | 4 | plugins: 5 | - '@hewmen/serverless-plugin-typescript' 6 | - serverless-plugin-optimize 7 | - serverless-offline 8 | # - serverless-plugin-warmup 9 | 10 | # custom: 11 | # # Enable warmup on all functions (only for production and staging) 12 | # warmup: 13 | # - production 14 | # - staging 15 | 16 | provider: 17 | name: aws 18 | runtime: nodejs8.10 19 | 20 | package: 21 | individually: true 22 | 23 | functions: 24 | main: 25 | handler: src/main.handler 26 | events: 27 | - http: 28 | method: any 29 | path: /{proxy+} 30 | -------------------------------------------------------------------------------- /aws-node-typescript-nest/src/app.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | 5 | describe('AppController', () => { 6 | let app: TestingModule; 7 | 8 | beforeAll(async () => { 9 | app = await Test.createTestingModule({ 10 | controllers: [AppController], 11 | providers: [AppService], 12 | }).compile(); 13 | }); 14 | 15 | describe('root', () => { 16 | it('should return "Hello World!"', () => { 17 | const appController = app.get(AppController); 18 | expect(appController.getHello()).toBe('Hello World!'); 19 | }); 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /aws-node-typescript-nest/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get('hello') 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /aws-node-typescript-nest/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | 5 | @Module({ 6 | imports: [], 7 | controllers: [AppController], 8 | providers: [AppService], 9 | }) 10 | export class AppModule {} 11 | -------------------------------------------------------------------------------- /aws-node-typescript-nest/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /aws-node-typescript-nest/test/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { INestApplication } from '@nestjs/common'; 2 | import { Test } from '@nestjs/testing'; 3 | import * as request from 'supertest'; 4 | import { AppModule } from './../src/app.module'; 5 | 6 | describe('AppController (e2e)', () => { 7 | let app: INestApplication; 8 | 9 | beforeAll(async () => { 10 | const moduleFixture = await Test.createTestingModule({ 11 | imports: [AppModule], 12 | }).compile(); 13 | 14 | app = moduleFixture.createNestApplication(); 15 | await app.init(); 16 | }); 17 | 18 | it('/hello (GET)', () => { 19 | return request(app.getHttpServer()) 20 | .get('/hello') 21 | .expect(200) 22 | .expect('Hello World!'); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /aws-node-typescript-nest/test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /aws-node-typescript-nest/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["src/**/*"], 4 | "exclude": ["node_modules", "**/*.spec.ts"] 5 | } 6 | -------------------------------------------------------------------------------- /aws-node-typescript-nest/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "noImplicitAny": false, 6 | "removeComments": true, 7 | "noLib": false, 8 | "allowSyntheticDefaultImports": true, 9 | "emitDecoratorMetadata": true, 10 | "experimentalDecorators": true, 11 | "target": "es6", 12 | "sourceMap": true, 13 | "outDir": "./dist", 14 | "baseUrl": "./" 15 | }, 16 | "exclude": ["node_modules"] 17 | } 18 | -------------------------------------------------------------------------------- /aws-node-typescript-nest/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "types": ["jest", "node"] 5 | }, 6 | "include": ["**/*.spec.ts", "**/*.d.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /aws-node-typescript-nest/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": ["tslint:recommended"], 4 | "jsRules": { 5 | "no-unused-expression": true 6 | }, 7 | "rules": { 8 | "quotemark": [true, "single"], 9 | "member-access": [false], 10 | "ordered-imports": [false], 11 | "max-line-length": [true, 150], 12 | "member-ordering": [false], 13 | "interface-name": [false], 14 | "arrow-parens": false, 15 | "object-literal-sort-keys": false 16 | }, 17 | "rulesDirectory": [] 18 | } 19 | -------------------------------------------------------------------------------- /aws-node-typescript-rest-api-with-dynamodb/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | -------------------------------------------------------------------------------- /aws-node-typescript-rest-api-with-dynamodb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typescript-example", 3 | "version": "0.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "watch": "tsc -w", 9 | "lint": "tslint '*.ts'" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "ISC", 14 | "devDependencies": { 15 | "@types/aws-sdk": "0.0.42", 16 | "@types/node": "^7.0.5", 17 | "tslint": "^5.5.0", 18 | "tslint-config-standard": "^6.0.1", 19 | "typescript": "^2.4.2" 20 | }, 21 | "dependencies": { 22 | "uuid": "^3.1.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /aws-node-typescript-rest-api-with-dynamodb/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs" 5 | }, 6 | "exclude": [ 7 | "node_modules" 8 | ], 9 | "types": [ 10 | "node", 11 | "aws-sdk" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /aws-node-typescript-rest-api-with-dynamodb/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint-config-standard" 3 | } 4 | -------------------------------------------------------------------------------- /aws-node-typescript-sqs-standard/.gitignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless 7 | 8 | # Webpack directories 9 | .webpack 10 | -------------------------------------------------------------------------------- /aws-node-typescript-sqs-standard/handler.ts: -------------------------------------------------------------------------------- 1 | export { default as sender } from './sqs/sender'; 2 | export { default as receiver } from './sqs/receiver'; 3 | -------------------------------------------------------------------------------- /aws-node-typescript-sqs-standard/sqs/receiver.ts: -------------------------------------------------------------------------------- 1 | import { SQSHandler, SQSMessageAttributes } from 'aws-lambda'; 2 | 3 | const receiver: SQSHandler = async (event) => { 4 | try { 5 | for (const record of event.Records) { 6 | const messageAttributes: SQSMessageAttributes = record.messageAttributes; 7 | console.log('Message Attributtes --> ', messageAttributes.AttributeNameHere.stringValue); 8 | console.log('Message Body --> ', record.body); 9 | // Do something 10 | } 11 | } catch (error) { 12 | console.log(error); 13 | } 14 | }; 15 | 16 | export default receiver; 17 | -------------------------------------------------------------------------------- /aws-node-typescript-sqs-standard/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowSyntheticDefaultImports": true, 4 | "esModuleInterop": true, 5 | "lib": ["esnext"], 6 | "module": "commonjs", 7 | "moduleResolution": "node", 8 | "noUnusedLocals": true, 9 | "noUnusedParameters": true, 10 | "outDir": "lib", 11 | "sourceMap": true, 12 | "target": "esnext" 13 | }, 14 | "exclude": ["node_modules"] 15 | } 16 | -------------------------------------------------------------------------------- /aws-node-typescript-sqs-standard/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["tslint-config-airbnb"] 3 | } -------------------------------------------------------------------------------- /aws-node-typescript-sqs-standard/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const slsw = require('serverless-webpack'); 3 | 4 | module.exports = { 5 | mode: slsw.lib.webpack.isLocal ? 'development' : 'production', 6 | entry: slsw.lib.entries, 7 | devtool: 'source-map', 8 | resolve: { 9 | extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'], 10 | }, 11 | output: { 12 | libraryTarget: 'commonjs', 13 | path: path.join(__dirname, '.webpack'), 14 | filename: '[name].js', 15 | }, 16 | target: 'node', 17 | module: { 18 | rules: [ 19 | // all files with a `.ts` or `.tsx` extension will be handled by `ts-loader` 20 | { test: /\.tsx?$/, loader: 'ts-loader' }, 21 | ], 22 | }, 23 | }; 24 | -------------------------------------------------------------------------------- /aws-node-upload-to-s3-and-postprocess/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | index.html 4 | -------------------------------------------------------------------------------- /aws-node-upload-to-s3-and-postprocess/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports.postprocess = (event) => { 4 | event.Records.forEach((record) => { 5 | const filename = record.s3.object.key; 6 | const filesize = record.s3.object.size; 7 | console.log(`New .png object has been created: ${filename} (${filesize} bytes)`); 8 | }); 9 | }; 10 | -------------------------------------------------------------------------------- /aws-node-upload-to-s3-and-postprocess/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "upload-to-s3-and-postprocess", 3 | "description": "Upload a files to S3 to trigger a lambda function.", 4 | "version": "1.0.0", 5 | "author": "Christoph Gysin ", 6 | "license": "MIT", 7 | "dependencies": { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /aws-node-upload-to-s3-and-postprocess/serverless.yml: -------------------------------------------------------------------------------- 1 | service: upload-to-s3-and-postprocess 2 | 3 | frameworkVersion: ">=1.1.0" 4 | 5 | custom: 6 | bucket: 7 | 8 | provider: 9 | name: aws 10 | runtime: nodejs8.10 11 | iamRoleStatements: 12 | - Effect: Allow 13 | Action: 14 | - s3:* 15 | Resource: "*" 16 | 17 | functions: 18 | postprocess: 19 | handler: handler.postprocess 20 | events: 21 | - s3: 22 | bucket: ${self:custom.bucket} 23 | event: s3:ObjectCreated:* 24 | rules: 25 | - suffix: .png 26 | -------------------------------------------------------------------------------- /aws-node-vue-nuxt-ssr/.gitignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless 7 | 8 | # Nuxt directories 9 | .nuxt -------------------------------------------------------------------------------- /aws-node-vue-nuxt-ssr/binaryMimeTypes.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | 'application/javascript', 3 | 'application/json', 4 | 'application/octet-stream', 5 | 'application/xml', 6 | 'font/eot', 7 | 'font/opentype', 8 | 'font/otf', 9 | 'image/jpeg', 10 | 'image/png', 11 | 'image/svg+xml', 12 | 'text/comma-separated-values', 13 | 'text/css', 14 | 'text/html', 15 | 'text/javascript', 16 | 'text/plain', 17 | 'text/text', 18 | 'text/xml', 19 | ]; 20 | -------------------------------------------------------------------------------- /aws-node-vue-nuxt-ssr/client/components/navbar.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /aws-node-vue-nuxt-ssr/client/layouts/default.vue: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /aws-node-vue-nuxt-ssr/client/pages/dogs/index.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 32 | -------------------------------------------------------------------------------- /aws-node-vue-nuxt-ssr/client/pages/index.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 17 | -------------------------------------------------------------------------------- /aws-node-vue-nuxt-ssr/index.js: -------------------------------------------------------------------------------- 1 | const sls = require('serverless-http'); 2 | const binaryMimeTypes = require('./binaryMimeTypes'); 3 | const nuxt = require('./nuxt'); 4 | 5 | module.exports.nuxt = sls(nuxt, { 6 | binary: binaryMimeTypes, 7 | }); 8 | -------------------------------------------------------------------------------- /aws-node-vue-nuxt-ssr/nuxt.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | mode: 'universal', 3 | 4 | head: { 5 | title: 'Vue Nuxt Test', 6 | meta: [ 7 | { charset: 'utf-8' }, 8 | { name: 'viewport', content: 'width=device-width, initial-scale=1' }, 9 | { hid: 'description', name: 'description', content: 'Nuxt.js project' }, 10 | ], 11 | }, 12 | 13 | srcDir: 'client/', 14 | 15 | modules: [ 16 | '@nuxt/http', 17 | ], 18 | 19 | http: { 20 | baseURL: 'https://api.thedogapi.com/v1/', 21 | }, 22 | 23 | render: { 24 | compressor: false, 25 | }, 26 | }; 27 | -------------------------------------------------------------------------------- /aws-node-vue-nuxt-ssr/nuxt.js: -------------------------------------------------------------------------------- 1 | const { Nuxt } = require('nuxt-start'); 2 | 3 | const config = require('./nuxt.config.js'); 4 | 5 | const nuxt = new Nuxt({ ...config, dev: false }); 6 | 7 | module.exports = (req, res) => 8 | nuxt.ready().then(() => nuxt.server.app(req, res)); 9 | -------------------------------------------------------------------------------- /aws-node-vue-nuxt-ssr/secrets.json: -------------------------------------------------------------------------------- 1 | { 2 | "NODE_ENV": "dev", 3 | "DOMAIN": "vuessr.yourdomain.com" 4 | } -------------------------------------------------------------------------------- /aws-node-websockets-authorizers/README.md: -------------------------------------------------------------------------------- 1 | 11 | 12 | # Simple Websockets Authorizers Example 13 | 14 | * Deploy the example service. 15 | * connect to the outputted wss url using `wscat`: 16 | 17 | ``` 18 | wscat -c 19 | ``` 20 | 21 | * Connection should fail. If you try again, this time specifying an `Auth` header: 22 | 23 | ``` 24 | wscat -c -H Auth:secret 25 | ``` 26 | * Connection succeeds. 27 | * Feel free to chat with yourself :) 28 | -------------------------------------------------------------------------------- /aws-node-websockets-authorizers/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-nodejs-websockets-authorizers", 3 | "version": "1.0.0", 4 | "description": "Simple example that demonstrates how to use authorizer functions with websocket events", 5 | "author": "", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-node-websockets-authorizers/serverless.yml: -------------------------------------------------------------------------------- 1 | service: websocket-authorizer-example 2 | 3 | provider: 4 | name: aws 5 | stage: dev 6 | runtime: nodejs8.10 7 | 8 | functions: 9 | connect: 10 | handler: handler.connect 11 | events: 12 | - websocket: 13 | route: $connect # authorizers are only for connect routes 14 | authorizer: 15 | name: auth 16 | identitySource: 17 | - 'route.request.header.Auth' 18 | default: 19 | handler: handler.default 20 | events: 21 | - websocket: 22 | route: $default 23 | 24 | auth: 25 | handler: handler.auth 26 | -------------------------------------------------------------------------------- /aws-python-alexa-skill/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | *.pyc 3 | *.pyo 4 | -------------------------------------------------------------------------------- /aws-python-alexa-skill/handler.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | 4 | def parseInt(value): 5 | try: 6 | return int(value) 7 | except ValueError: 8 | return 100 9 | 10 | 11 | def lucky_number(event, context): 12 | print(event) 13 | upperLimitDict = event['request']['intent']['slots']['UpperLimit'] 14 | upperLimit = None 15 | if 'value' in upperLimitDict: 16 | upperLimit = parseInt(upperLimitDict['value']) 17 | else: 18 | upperLimit = 100 19 | 20 | number = random.randint(0, upperLimit) 21 | response = { 22 | 'version': '1.0', 23 | 'response': { 24 | 'outputSpeech': { 25 | 'type': 'PlainText', 26 | 'text': 'Your lucky number is ' + str(number), 27 | } 28 | } 29 | } 30 | 31 | return response 32 | -------------------------------------------------------------------------------- /aws-python-alexa-skill/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-alexa-skill", 3 | "version": "1.0.0", 4 | "description": "This example demonstrates how to use an AWS Lambdas for your custom Alexa skill.", 5 | "author": "", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-python-alexa-skill/serverless.yml: -------------------------------------------------------------------------------- 1 | service: aws-python-alexa-skill 2 | 3 | frameworkVersion: ">=1.4.0 <2.0.0" 4 | 5 | provider: 6 | name: aws 7 | runtime: python2.7 8 | 9 | functions: 10 | luckyNumber: 11 | handler: handler.lucky_number 12 | events: 13 | - alexaSkill 14 | -------------------------------------------------------------------------------- /aws-python-auth0-custom-authorizers-api/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | secrets.json 4 | public_key 5 | /frontend/misc.md 6 | vendored 7 | -------------------------------------------------------------------------------- /aws-python-auth0-custom-authorizers-api/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-auth0-api-gateway", 3 | "version": "1.0.0", 4 | "description": "Demonstration of protecting API gateway endpoints with auth0", 5 | "license": "MIT", 6 | "dependencies": { 7 | "serverless": "^1.28.0" 8 | }, 9 | "devDependencies": { 10 | "serverless-offline": "^3.18.0" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /aws-python-auth0-custom-authorizers-api/public_key-example: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | PUBLIC KEY - can be found in https://manage.auth0.com -> clients -> advanced settings -> Certificates 3 | Replace this file with public_key 4 | -----END CERTIFICATE----- 5 | -------------------------------------------------------------------------------- /aws-python-auth0-custom-authorizers-api/requirements.txt: -------------------------------------------------------------------------------- 1 | cryptography==2.3 2 | PyJWT==1.6.4 3 | -------------------------------------------------------------------------------- /aws-python-auth0-custom-authorizers-api/secrets.example.json: -------------------------------------------------------------------------------- 1 | { 2 | "AUTH0_CLIENT_ID": "your-client-id", 3 | "AUTH0_CLIENT_SECRET": "your-client-secret" 4 | } -------------------------------------------------------------------------------- /aws-python-line-echo-bot/handler.py: -------------------------------------------------------------------------------- 1 | import json 2 | from linebot import ( 3 | LineBotApi, WebhookHandler 4 | ) 5 | from linebot.models import ( 6 | MessageEvent, TextMessage, TextSendMessage, 7 | ) 8 | 9 | 10 | def webhook(event, context): 11 | line_bot_api = LineBotApi('YOUR_CHANNEL_ACCESS_TOKEN') 12 | handler = WebhookHandler('YOUR_CHANNEL_SECRET') 13 | 14 | msg = json.loads(event['body']) 15 | line_bot_api.reply_message( 16 | msg['events'][0]['replyToken'], 17 | TextSendMessage(text=msg['events'][0]['message']['text']) 18 | ) 19 | response = { 20 | "statusCode": 200, 21 | "body": json.dumps({"message": 'ok'}) 22 | } 23 | 24 | return response 25 | -------------------------------------------------------------------------------- /aws-python-line-echo-bot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-python-line-echo-bot", 3 | "description": "this is echo bot on LINE message", 4 | "version": "0.1.0", 5 | "dependencies": {}, 6 | "devDependencies": { 7 | "serverless-python-requirements": "^4.3.0" 8 | }, 9 | "main": "handler.py", 10 | "autor": "NiJia", 11 | "license": "MIT" 12 | } 13 | -------------------------------------------------------------------------------- /aws-python-line-echo-bot/requirements.txt: -------------------------------------------------------------------------------- 1 | line-bot-sdk==1.12.1 -------------------------------------------------------------------------------- /aws-python-line-echo-bot/serverless.yml: -------------------------------------------------------------------------------- 1 | service: aws-python-line-echo-bot 2 | provider: 3 | name: aws 4 | runtime: python3.7 5 | 6 | functions: 7 | line_bot: 8 | handler: handler.webhook 9 | events: 10 | - http: 11 | path: /webhook 12 | method: POST 13 | plugins: 14 | - serverless-python-requirements 15 | -------------------------------------------------------------------------------- /aws-python-line-echo-bot/setup.cfg: -------------------------------------------------------------------------------- 1 | [install] 2 | prefix= -------------------------------------------------------------------------------- /aws-python-pynamodb-s3-sigurl/asset/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localstack/serverless-examples/c4874f3cb38d67d64f90cc2d444941c55d8064b9/aws-python-pynamodb-s3-sigurl/asset/__init__.py -------------------------------------------------------------------------------- /aws-python-pynamodb-s3-sigurl/asset/list.py: -------------------------------------------------------------------------------- 1 | import http.client as httplib 2 | from asset.asset_model import AssetModel 3 | from log_cfg import logger 4 | 5 | 6 | def asset_list(event, context): 7 | logger.debug('event: {}, context: {}'.format(event, context)) 8 | 9 | results = AssetModel.scan() 10 | return { 11 | 'statusCode': httplib.OK, 12 | 'body': { 13 | 'items': [dict(result) for result in results] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /aws-python-pynamodb-s3-sigurl/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-python-pynamodb-s3-sigurl", 3 | "version": "1.0.0", 4 | "description": "Serverless signed uploader REST API using pynamodb, s3 generated events, custom log format, and DRY serverless.yml with custom section", 5 | "author": "Bruce Edge", 6 | "license": "MIT", 7 | "dependencies": { 8 | "serverless-python-requirements": "^5.0.1" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aws-python-pynamodb-s3-sigurl/requirements.txt: -------------------------------------------------------------------------------- 1 | pynamodb>=3.1.0 2 | boto3 #no-deploy 3 | botocore #no-deploy -------------------------------------------------------------------------------- /aws-python-rest-api-with-dynamodb/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | *.pyc 3 | *.pyo 4 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-dynamodb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-rest-with-dynamodb", 3 | "version": "1.0.0", 4 | "description": "Serverless CRUD service exposing a REST HTTP interface", 5 | "author": "", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-dynamodb/todos/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localstack/serverless-examples/c4874f3cb38d67d64f90cc2d444941c55d8064b9/aws-python-rest-api-with-dynamodb/todos/__init__.py -------------------------------------------------------------------------------- /aws-python-rest-api-with-dynamodb/todos/decimalencoder.py: -------------------------------------------------------------------------------- 1 | import decimal 2 | import json 3 | 4 | 5 | # This is a workaround for: http://bugs.python.org/issue16535 6 | class DecimalEncoder(json.JSONEncoder): 7 | def default(self, obj): 8 | if isinstance(obj, decimal.Decimal): 9 | return int(obj) 10 | return super(DecimalEncoder, self).default(obj) 11 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-dynamodb/todos/delete.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import boto3 4 | dynamodb = boto3.resource('dynamodb') 5 | 6 | 7 | def delete(event, context): 8 | table = dynamodb.Table(os.environ['DYNAMODB_TABLE']) 9 | 10 | # delete the todo from the database 11 | table.delete_item( 12 | Key={ 13 | 'id': event['pathParameters']['id'] 14 | } 15 | ) 16 | 17 | # create a response 18 | response = { 19 | "statusCode": 200 20 | } 21 | 22 | return response 23 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-dynamodb/todos/get.py: -------------------------------------------------------------------------------- 1 | import os 2 | import json 3 | 4 | from todos import decimalencoder 5 | import boto3 6 | dynamodb = boto3.resource('dynamodb') 7 | 8 | 9 | def get(event, context): 10 | table = dynamodb.Table(os.environ['DYNAMODB_TABLE']) 11 | 12 | # fetch todo from the database 13 | result = table.get_item( 14 | Key={ 15 | 'id': event['pathParameters']['id'] 16 | } 17 | ) 18 | 19 | # create a response 20 | response = { 21 | "statusCode": 200, 22 | "body": json.dumps(result['Item'], 23 | cls=decimalencoder.DecimalEncoder) 24 | } 25 | 26 | return response 27 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-dynamodb/todos/list.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | 4 | from todos import decimalencoder 5 | import boto3 6 | dynamodb = boto3.resource('dynamodb') 7 | 8 | 9 | def list(event, context): 10 | table = dynamodb.Table(os.environ['DYNAMODB_TABLE']) 11 | 12 | # fetch all todos from the database 13 | result = table.scan() 14 | 15 | # create a response 16 | response = { 17 | "statusCode": 200, 18 | "body": json.dumps(result['Items'], cls=decimalencoder.DecimalEncoder) 19 | } 20 | 21 | return response 22 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-faunadb/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | .requirements 3 | venv 4 | *.pyc 5 | *.pyo 6 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-faunadb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-rest-with-faunadb", 3 | "version": "1.0.0", 4 | "description": "Serverless CRUD service exposing a REST HTTP interface", 5 | "author": "", 6 | "license": "MIT", 7 | "dependencies": { 8 | "serverless-python-requirements": "^2.0.0-beta.6" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-faunadb/requirements.txt: -------------------------------------------------------------------------------- 1 | faunadb==0.1.2 2 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-faunadb/todos/__init__.py: -------------------------------------------------------------------------------- 1 | import json 2 | import logging 3 | import os 4 | 5 | from faunadb.client import FaunaClient 6 | from faunadb.objects import Ref 7 | from faunadb import query 8 | 9 | client = FaunaClient(secret=os.environ['FAUNADB_SECRET']) 10 | 11 | TODOS = Ref('classes/todos') 12 | ALL_TODOS = query.index('all_todos') 13 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-faunadb/todos/delete.py: -------------------------------------------------------------------------------- 1 | from todos import client, TODOS 2 | 3 | from faunadb.objects import Ref 4 | from faunadb import query 5 | 6 | def delete(event, context): 7 | # delete the todo from the database 8 | client.query(query.delete(Ref(TODOS, event['pathParameters']['id']))) 9 | 10 | # create a response 11 | response = { 12 | "statusCode": 200 13 | } 14 | 15 | return response 16 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-faunadb/todos/get.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | from todos.makeresult import make_result 4 | from todos import client, TODOS 5 | 6 | from faunadb.objects import Ref 7 | from faunadb import query 8 | 9 | def get(event, context): 10 | # fetch todo from the database 11 | ref = Ref(TODOS, event['pathParameters']['id']) 12 | fetched = client.query(query.get(ref)) 13 | 14 | # create a response 15 | response = { 16 | "statusCode": 200, 17 | "body": json.dumps(make_result(fetched)) 18 | } 19 | 20 | return response 21 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-faunadb/todos/list.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | from todos.makeresult import make_result 4 | from todos import client, ALL_TODOS 5 | 6 | from faunadb import query 7 | 8 | def list(event, context): 9 | # fetch all todos from the database 10 | results = client.query( 11 | query.map_expr(lambda ref: query.get(ref), 12 | query.paginate(query.match(ALL_TODOS)))) 13 | 14 | # create a response 15 | response = { 16 | "statusCode": 200, 17 | "body": json.dumps(map(make_result, results['data'])) 18 | } 19 | 20 | return response 21 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-faunadb/todos/makeresult.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | def _to_epoch(fauna_time): 4 | return int(time.mktime(fauna_time.to_datetime().timetuple()) * 1000) 5 | 6 | def make_result(value): 7 | return { 8 | 'id': value['ref'].id(), 9 | 'text': value['data']['text'], 10 | 'checked': value['data']['checked'], 11 | 'createdAt': _to_epoch(value['data']['createdAt']), 12 | 'updatedAt': _to_epoch(value['data']['updatedAt']) 13 | } 14 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-faunadb/todos/schema.py: -------------------------------------------------------------------------------- 1 | from todos import client, TODOS, ALL_TODOS 2 | 3 | from faunadb import query 4 | 5 | def schema(event, context): 6 | create_todos = query.create_class({ 7 | 'name': 'todos' 8 | }) 9 | 10 | create_all_todos = query.create_index({ 11 | 'name': 'all_todos', 12 | 'source': TODOS 13 | }) 14 | 15 | client.query(query.if_expr( 16 | query.exists(TODOS), 17 | query.get(TODOS), 18 | create_todos 19 | )) 20 | 21 | client.query(query.if_expr( 22 | query.exists(ALL_TODOS), 23 | query.get(ALL_TODOS), 24 | create_all_todos 25 | )) 26 | 27 | # create a response 28 | response = { 29 | "statusCode": 200 30 | } 31 | 32 | return response 33 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-pymongo/item/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localstack/serverless-examples/c4874f3cb38d67d64f90cc2d444941c55d8064b9/aws-python-rest-api-with-pymongo/item/__init__.py -------------------------------------------------------------------------------- /aws-python-rest-api-with-pymongo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-python-rest-api-with-pymongo", 3 | "version": "1.0.0", 4 | "description": "Serverless pymongo example", 5 | "author": "", 6 | "license": "MIT", 7 | "dependencies": { 8 | "serverless-python-requirements": "^5.0.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-pymongo/requirements.txt: -------------------------------------------------------------------------------- 1 | pymongo 2 | dnspython 3 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-pynamodb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-rest-with-pynamodb", 3 | "version": "1.0.0", 4 | "description": "Serverless CRUD service exposing a REST HTTP interface", 5 | "author": "", 6 | "license": "MIT", 7 | "dependencies": { 8 | "serverless-python-requirements": "^2.4.1" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-pynamodb/requirements.txt: -------------------------------------------------------------------------------- 1 | pynamodb==4.3.1 2 | boto3 #no-deploy 3 | botocore #no-deploy 4 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-pynamodb/todos/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localstack/serverless-examples/c4874f3cb38d67d64f90cc2d444941c55d8064b9/aws-python-rest-api-with-pynamodb/todos/__init__.py -------------------------------------------------------------------------------- /aws-python-rest-api-with-pynamodb/todos/delete.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | from pynamodb.exceptions import DoesNotExist, DeleteError 4 | from todos.todo_model import TodoModel 5 | 6 | 7 | def delete(event, context): 8 | try: 9 | found_todo = TodoModel.get(hash_key=event['path']['todo_id']) 10 | except DoesNotExist: 11 | return {'statusCode': 404, 12 | 'body': json.dumps({'error_message': 'TODO was not found'})} 13 | try: 14 | found_todo.delete() 15 | except DeleteError: 16 | return {'statusCode': 400, 17 | 'body': json.dumps({'error_message': 'Unable to delete the TODO'})} 18 | 19 | # create a response 20 | return {'statusCode': 204} 21 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-pynamodb/todos/get.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | from pynamodb.exceptions import DoesNotExist 4 | from todos.todo_model import TodoModel 5 | 6 | 7 | def get(event, context): 8 | try: 9 | found_todo = TodoModel.get(hash_key=event['path']['todo_id']) 10 | except DoesNotExist: 11 | return {'statusCode': 404, 12 | 'body': json.dumps({'error_message': 'TODO was not found'})} 13 | 14 | # create a response 15 | return {'statusCode': 200, 16 | 'body': json.dumps(dict(found_todo))} 17 | -------------------------------------------------------------------------------- /aws-python-rest-api-with-pynamodb/todos/list.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | from todos.todo_model import TodoModel 4 | 5 | 6 | def todo_list(event, context): 7 | # fetch all todos from the database 8 | results = TodoModel.scan() 9 | 10 | # create a response 11 | return {'statusCode': 200, 12 | 'body': json.dumps({'items': [dict(result) for result in results]})} 13 | -------------------------------------------------------------------------------- /aws-python-scheduled-cron/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | *.pyc 3 | *.pyo 4 | -------------------------------------------------------------------------------- /aws-python-scheduled-cron/handler.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import logging 3 | 4 | logger = logging.getLogger(__name__) 5 | logger.setLevel(logging.INFO) 6 | 7 | 8 | def run(event, context): 9 | current_time = datetime.datetime.now().time() 10 | name = context.function_name 11 | logger.info("Your cron function " + name + " ran at " + str(current_time)) 12 | -------------------------------------------------------------------------------- /aws-python-scheduled-cron/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-scheduled-cron", 3 | "version": "1.0.0", 4 | "description": "Example of creating a function that runs as a cron job using the serverless `schedule` event", 5 | "author": "", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-python-scheduled-cron/serverless.yml: -------------------------------------------------------------------------------- 1 | service: aws-python-scheduled-cron 2 | 3 | frameworkVersion: ">=1.2.0 <2.0.0" 4 | 5 | provider: 6 | name: aws 7 | runtime: python2.7 8 | 9 | functions: 10 | cron: 11 | handler: handler.run 12 | events: 13 | # Invoke Lambda function every minute 14 | - schedule: rate(1 minute) 15 | secondCron: 16 | handler: handler.run 17 | events: 18 | # Invoke Lambda function every 2nd minute from Mon-Fri 19 | - schedule: cron(0/2 * ? * MON-FRI *) 20 | -------------------------------------------------------------------------------- /aws-python-simple-http-endpoint/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | *.pyc 3 | *.pyo 4 | -------------------------------------------------------------------------------- /aws-python-simple-http-endpoint/handler.py: -------------------------------------------------------------------------------- 1 | import json 2 | import datetime 3 | 4 | 5 | def endpoint(event, context): 6 | current_time = datetime.datetime.now().time() 7 | body = { 8 | "message": "Hello, the current time is " + str(current_time) 9 | } 10 | 11 | response = { 12 | "statusCode": 200, 13 | "body": json.dumps(body) 14 | } 15 | 16 | return response 17 | -------------------------------------------------------------------------------- /aws-python-simple-http-endpoint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-simple-http-endpoint", 3 | "version": "1.0.0", 4 | "description": "Example demonstrates how to setup a simple HTTP GET endpoint with python", 5 | "author": "", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-python-simple-http-endpoint/serverless.yml: -------------------------------------------------------------------------------- 1 | service: aws-python-simple-http-endpoint 2 | 3 | frameworkVersion: ">=1.2.0 <2.0.0" 4 | 5 | provider: 6 | name: aws 7 | runtime: python2.7 # or python3.7, supported as of November 2018 8 | 9 | functions: 10 | currentTime: 11 | handler: handler.endpoint 12 | events: 13 | - http: 14 | path: ping 15 | method: get 16 | -------------------------------------------------------------------------------- /aws-python-telegram-bot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "serverless-telegram-bot", 3 | "description": "This example demonstrates how to setup an echo Telegram Bot using the Serverless Framework ⚡🤖 ", 4 | "version": "0.1.0", 5 | "repository": { 6 | "type": "git", 7 | "url": "git+https://github.com/jonatasbaldin/serverless-telegram-bot.git" 8 | }, 9 | "keywords": [ 10 | "python", 11 | "aws", 12 | "lambda", 13 | "serverless" 14 | ], 15 | "author": "jonatasbaldin", 16 | "license": "MIT", 17 | "dependencies": { 18 | "serverless-python-requirements": "^3.0.9" 19 | }, 20 | "bugs": { 21 | "url": "https://github.com/jonatasbaldin/serverless-telegram-bot/issues" 22 | }, 23 | "homepage": "https://github.com/jonatasbaldin/serverless-telegram-bot#readme" 24 | } 25 | -------------------------------------------------------------------------------- /aws-python-telegram-bot/requirements.txt: -------------------------------------------------------------------------------- 1 | python-telegram-bot==8.1.1 2 | -------------------------------------------------------------------------------- /aws-python-telegram-bot/serverless.yml: -------------------------------------------------------------------------------- 1 | service: serverless-telegram-bot 2 | 3 | provider: 4 | name: aws 5 | runtime: python3.6 6 | profile: ckl 7 | environment: 8 | TELEGRAM_TOKEN: ${file(./serverless.env.yml):TELEGRAM_TOKEN, ''} 9 | 10 | functions: 11 | webhook: 12 | handler: handler.webhook 13 | events: 14 | - http: POST / 15 | 16 | set_webhook: 17 | handler: handler.set_webhook 18 | events: 19 | - http: POST /set_webhook 20 | 21 | plugins: 22 | - serverless-python-requirements 23 | -------------------------------------------------------------------------------- /aws-ruby-line-bot/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | vendor 3 | node_modules 4 | package-lock.json 5 | .bundle/ -------------------------------------------------------------------------------- /aws-ruby-line-bot/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'line-bot-api' 4 | -------------------------------------------------------------------------------- /aws-ruby-line-bot/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | line-bot-api (1.11.0) 5 | 6 | PLATFORMS 7 | ruby 8 | 9 | DEPENDENCIES 10 | line-bot-api 11 | 12 | BUNDLED WITH 13 | 2.0.2 14 | -------------------------------------------------------------------------------- /aws-ruby-line-bot/handler.rb: -------------------------------------------------------------------------------- 1 | require 'line/bot' 2 | 3 | def webhook(event:, context:) 4 | client ||= Line::Bot::Client.new { |config| 5 | config.channel_secret = "YOUR_LINE_CHANNEL_SECRET" 6 | config.channel_token = "YOUR_LINE_CHANNEL_TOKEN" 7 | } 8 | 9 | event = JSON.parse(event["body"]) 10 | reply_token = event["events"][0]["replyToken"] 11 | message = { 12 | type: 'text', 13 | text: event["events"][0]["message"]["text"] 14 | } 15 | 16 | response = client.reply_message(reply_token, message) 17 | 18 | { statusCode: 200, body: JSON.generate({message: "OK"}) } 19 | end -------------------------------------------------------------------------------- /aws-ruby-line-bot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-ruby-line-bot", 3 | "version": "1.0.0", 4 | "description": "Example demonstrates how to setup a simple Line echo bot on AWS", 5 | "author": "NiJia", 6 | "license": "MIT", 7 | "devDependencies": { 8 | "serverless-hooks-plugin": "^1.1.0" 9 | } 10 | } -------------------------------------------------------------------------------- /aws-ruby-line-bot/serverless.yml: -------------------------------------------------------------------------------- 1 | service: aws-ruby-line-bot 2 | 3 | frameworkVersion: ">=1.1.0 <2.0.0" 4 | 5 | provider: 6 | name: aws 7 | runtime: ruby2.5 8 | 9 | functions: 10 | webhook: 11 | handler: handler.webhook 12 | events: 13 | - http: 14 | path: webhook 15 | method: post 16 | 17 | plugins: 18 | - serverless-hooks-plugin 19 | 20 | custom: 21 | hooks: 22 | package:initialize: 23 | - bundle install --deployment 24 | -------------------------------------------------------------------------------- /aws-ruby-simple-http-endpoint/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | vendor -------------------------------------------------------------------------------- /aws-ruby-simple-http-endpoint/handler.rb: -------------------------------------------------------------------------------- 1 | def endpoint(event:, context:) 2 | hash = {date: Time.new} 3 | { statusCode: 200, body: JSON.generate(hash) } 4 | end -------------------------------------------------------------------------------- /aws-ruby-simple-http-endpoint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-ruby-simple-http-endpoint", 3 | "version": "1.0.0", 4 | "description": "Example demonstrates how to setup a simple HTTP GET endpoint", 5 | "author": "", 6 | "license": "MIT" 7 | } 8 | -------------------------------------------------------------------------------- /aws-ruby-simple-http-endpoint/serverless.yml: -------------------------------------------------------------------------------- 1 | service: serverless-ruby-simple-http-endpoint 2 | 3 | frameworkVersion: ">=1.1.0 <2.0.0" 4 | 5 | provider: 6 | name: aws 7 | runtime: ruby2.5 8 | 9 | functions: 10 | current_time: 11 | handler: handler.endpoint 12 | events: 13 | - http: 14 | path: ping 15 | method: get -------------------------------------------------------------------------------- /azure-node-line-bot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "azure-nodejs", 3 | "version": "1.0.0", 4 | "description": "Azure Functions sample for the Serverless framework", 5 | "main": "handler.js", 6 | "keywords": [ 7 | "azure", 8 | "serverless" 9 | ], 10 | "devDependencies": { 11 | "serverless-azure-functions": "*" 12 | }, 13 | "dependencies": { 14 | "@line/bot-sdk": "^6.3.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /azure-node-simple-http-endpoint/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | functions 3 | .serverless -------------------------------------------------------------------------------- /azure-node-simple-http-endpoint/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports.hello = (context, req) => { 4 | context.log('JavaScript HTTP trigger function processed a request.'); 5 | 6 | const res = {}; 7 | 8 | if (req.query.name || (req.body && req.body.name)) { 9 | const name = req.query.name || req.body.name; 10 | 11 | res.body = `Hello ${name}`; 12 | } else { 13 | res.status = 400; 14 | res.body = 'Please pass a name on the query string or in the request body'; 15 | } 16 | 17 | context.done(null, res); 18 | }; 19 | -------------------------------------------------------------------------------- /azure-node-simple-http-endpoint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "azure-node-simple-http-endpoint", 3 | "version": "0.1.0", 4 | "description": "An example of making http endpoints with the Azure Functions Serverless Framework plugin", 5 | "main": "index.js", 6 | "author": "serverless.com", 7 | "license": "MIT", 8 | "dependencies": { 9 | "serverless-azure-functions": "^0.2.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /azure-node-simple-http-endpoint/serverless.yml: -------------------------------------------------------------------------------- 1 | service: azfx-node-http 2 | 3 | provider: 4 | name: azure 5 | location: West US 6 | 7 | plugins: 8 | - serverless-azure-functions 9 | 10 | package: 11 | exclude: 12 | - node_modules/** 13 | - .gitignore 14 | - package.json 15 | - .git/** 16 | 17 | functions: 18 | hello: 19 | handler: handler.hello 20 | events: 21 | - http: true 22 | x-azure-settings: 23 | authLevel: anonymous 24 | -------------------------------------------------------------------------------- /azure-node-telegram-bot/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const request = require('request'); 4 | 5 | module.exports = (context, req) => { 6 | const token = 'YOUR_API_TOKEN'; 7 | const BASE_URL = `https://api.telegram.org/bot${token}/sendMessage`; 8 | 9 | const chatId = req.body.message.chat.id; 10 | 11 | request.post(BASE_URL).form({ text: 'Hello World!', chat_id: chatId }); 12 | 13 | const res = { 14 | // status: 200, /* Defaults to 200 */ 15 | body: 'ok', 16 | }; 17 | context.done(null, res); 18 | }; 19 | -------------------------------------------------------------------------------- /azure-node-telegram-bot/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "azure-nodejs", 3 | "version": "1.0.0", 4 | "description": "Azure Functions sample for the Serverless framework", 5 | "main": "handler.js", 6 | "keywords": [ 7 | "azure", 8 | "serverless" 9 | ], 10 | "devDependencies": { 11 | "serverless-azure-functions": "*" 12 | }, 13 | "dependencies": { 14 | "lint": "^1.1.2", 15 | "request": "^2.88.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /check-if-readme-is-up-to-date.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Checking if README.md has been updated..." 4 | 5 | git update-index --refresh 6 | 7 | if ! git diff-index --quiet HEAD -- README.md; then 8 | echo "README.md needs to be regenerated!" 9 | echo 10 | echo "Please run:" 11 | echo " $ npm run docs" 12 | exit 1 13 | fi 14 | 15 | exit 0 16 | -------------------------------------------------------------------------------- /google-golang-simple-http-endpoint/.gcloudignore: -------------------------------------------------------------------------------- 1 | # This file specifies files that are *not* uploaded to Google Cloud Platform 2 | # using gcloud. It follows the same syntax as .gitignore, with the addition of 3 | # "#!include" directives (which insert the entries of the given .gitignore-style 4 | # file at that point). 5 | # 6 | # For more information, run: 7 | # $ gcloud topic gcloudignore 8 | # 9 | .gcloudignore 10 | # If you would like to upload your .git directory, .gitignore file or files 11 | # from your .gitignore file, remove the corresponding line 12 | # below: 13 | .git 14 | .gitignore 15 | 16 | node_modules 17 | .serverless 18 | -------------------------------------------------------------------------------- /google-golang-simple-http-endpoint/hello.go: -------------------------------------------------------------------------------- 1 | package hello 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "net/http" 7 | ) 8 | 9 | // Hello is a simple HTTP handler that addresses HTTP requests to the /hello endpoint 10 | func Hello(w http.ResponseWriter, r *http.Request) { 11 | var buf bytes.Buffer 12 | 13 | body, err := json.Marshal(map[string]interface{}{ 14 | "message": "Go Serverless v1! Your function executed hello successfully!", 15 | }) 16 | if err != nil { 17 | w.WriteHeader(http.StatusNotFound) 18 | w.Write([]byte(err.Error())) 19 | return 20 | } 21 | json.HTMLEscape(&buf, body) 22 | 23 | w.WriteHeader(http.StatusOK) 24 | w.Header().Set("Content-Type", "application/json") 25 | w.Header().Set("MyCompany-Func-Reply", "hello-handler") 26 | w.Write(buf.Bytes()) 27 | } 28 | -------------------------------------------------------------------------------- /google-golang-simple-http-endpoint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "google-golang-simple-http-endpoint", 3 | "version": "0.0.1", 4 | "description": "Example demonstrates how to setup a simple HTTP GET endpoint with golang", 5 | "author": "Sebastian Borza ", 6 | "license": "MIT", 7 | "main": "handler.py", 8 | "scripts": { 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "dependencies": { 12 | "serverless-google-cloudfunctions": "^2.1.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /google-node-simple-http-endpoint/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.http = (request, response) => { 4 | response.status(200).send('Hello World!'); 5 | }; 6 | -------------------------------------------------------------------------------- /google-node-simple-http-endpoint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "google-node-simple-http-endpoint", 3 | "version": "0.1.0", 4 | "description": "An example of making http endpoints with the Google Cloud Functions Serverless Framework plugin.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "serverless.com", 10 | "license": "MIT", 11 | "dependencies": { 12 | "serverless-google-cloudfunctions": "^1.1.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /google-node-simple-http-endpoint/serverless.yml: -------------------------------------------------------------------------------- 1 | service: node-simple-http-endpoint # NOTE: Don't put the word "google" in here 2 | 3 | provider: 4 | name: google 5 | runtime: nodejs 6 | project: my-project-1234 7 | credentials: ~/.gcloud/keyfile.json # path must be absolute 8 | 9 | plugins: 10 | - serverless-google-cloudfunctions 11 | 12 | package: 13 | exclude: 14 | - node_modules/** 15 | - .gitignore 16 | - .git/** 17 | 18 | functions: 19 | helloWorld: 20 | handler: http 21 | events: 22 | - http: path 23 | -------------------------------------------------------------------------------- /google-node-typescript-http-endpoint/README.md: -------------------------------------------------------------------------------- 1 | 12 | # gcp-node-typescript-simple 13 | Simple HTTP example for GCP functions by Serverless framework with Typescript 14 | 15 | ## Credentials 16 | - [Google Cloud Platform credential](https://serverless.com/framework/docs/providers/google/guide/credentials/) 17 | 18 | ## Get Started 19 | ### install dependencies 20 | ``` 21 | $ npm i 22 | ``` 23 | 24 | ### deploy 25 | ``` 26 | $ serverless deploy 27 | ``` -------------------------------------------------------------------------------- /google-node-typescript-http-endpoint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gcp-node-typescript-simple", 3 | "version": "0.1.0", 4 | "description": "Simple HTTP example for GCP functions by Serverless framework with Typescript", 5 | "main": "/src/App.ts", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "serverless.com", 10 | "license": "MIT", 11 | "devDependencies": { 12 | "awesome-typescript-loader": "^5.2.1", 13 | "serverless-google-cloudfunctions": "^1.2.0", 14 | "typescript": "^3.1.6", 15 | "@types/node": "^7.0.5" 16 | }, 17 | "dependencies": {} 18 | } 19 | -------------------------------------------------------------------------------- /google-node-typescript-http-endpoint/src/App.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.http = (request, response) => { 4 | response.status(200).send("Hello World! Let's start Typescript!!"); 5 | }; 6 | 7 | exports.event = (event, callback) => { 8 | callback(); 9 | }; 10 | -------------------------------------------------------------------------------- /google-node-typescript-http-endpoint/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | }, 6 | "include": [ 7 | "src/**/*.ts" 8 | ], 9 | "exclude": [ 10 | "node_modules" 11 | ], 12 | "types": [ 13 | "node", 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /google-python-simple-http-endpoint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "google-python-simple-http-endpoint", 3 | "version": "0.0.1", 4 | "description": "Example demonstrates how to setup a simple HTTP GET endpoint with python", 5 | "author": "Sebastian Borza ", 6 | "license": "MIT", 7 | "main": "handler.py", 8 | "scripts": { 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "dependencies": { 12 | "serverless-google-cloudfunctions": "^2.1.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /google-python-simple-http-endpoint/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localstack/serverless-examples/c4874f3cb38d67d64f90cc2d444941c55d8064b9/google-python-simple-http-endpoint/requirements.txt -------------------------------------------------------------------------------- /google-python-simple-http-endpoint/serverless.yml: -------------------------------------------------------------------------------- 1 | service: python-simple-http-endpoint 2 | 3 | frameworkVersion: ">=1.2.0 <2.0.0" 4 | 5 | package: 6 | exclude: 7 | - node_modules/** 8 | - .gitignore 9 | - .git/** 10 | 11 | plugins: 12 | - serverless-google-cloudfunctions 13 | 14 | provider: 15 | name: google 16 | runtime: python37 17 | project: 18 | credentials: ~/.gcloud/keyfile.json # path must be absolute 19 | 20 | functions: 21 | currentTime: 22 | handler: endpoint 23 | events: 24 | - http: path 25 | -------------------------------------------------------------------------------- /kubeless-python-simple-function/handler.py: -------------------------------------------------------------------------------- 1 | def hello(event, context): 2 | return "Hello " + event['data'] + "!" 3 | 4 | -------------------------------------------------------------------------------- /kubeless-python-simple-function/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kubeless-python-simple-function", 3 | "version": "0.0.1", 4 | "description": "This example demonstrates how to setup a simple Python function with Kubeless", 5 | "dependencies": { 6 | "bluebird": "^3.5.0", 7 | "kubernetes-client": "^3.10.1", 8 | "serverless-kubeless": "^0.4.0" 9 | }, 10 | "main": "handler.py", 11 | "autor": "Bitnami", 12 | "license": "ASL" 13 | } 14 | -------------------------------------------------------------------------------- /kubeless-python-simple-function/serverless.yml: -------------------------------------------------------------------------------- 1 | service: python-hello 2 | 3 | provider: 4 | name: kubeless 5 | runtime: python2.7 6 | 7 | plugins: 8 | - serverless-kubeless 9 | 10 | functions: 11 | hello: 12 | handler: handler.hello 13 | -------------------------------------------------------------------------------- /kubeless-python-simple-scheduled-function/handler.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | def printClock(event, context): 3 | now = datetime.now() 4 | clock = "%02d:%02d" % (now.hour,now.minute) 5 | print clock 6 | return clock 7 | -------------------------------------------------------------------------------- /kubeless-python-simple-scheduled-function/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kubeless-python-simple-scheduled-function", 3 | "version": "0.0.1", 4 | "description": "This example demonstrates how to setup a simple Python function with Kubeless", 5 | "dependencies": { 6 | "bluebird": "^3.5.0", 7 | "kubernetes-client": "^3.10.1", 8 | "serverless-kubeless": "^0.4.0" 9 | }, 10 | "main": "handler.py", 11 | "autor": "Bitnami", 12 | "license": "ASL" 13 | } 14 | -------------------------------------------------------------------------------- /kubeless-python-simple-scheduled-function/serverless.yml: -------------------------------------------------------------------------------- 1 | service: python-clock 2 | 3 | provider: 4 | name: kubeless 5 | runtime: python2.7 6 | 7 | plugins: 8 | - serverless-kubeless 9 | 10 | functions: 11 | clock: 12 | handler: handler.printClock 13 | events: 14 | - schedule: '* * * * *' 15 | -------------------------------------------------------------------------------- /openwhisk-go-simple/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | *.pyc 3 | *.pyo 4 | -------------------------------------------------------------------------------- /openwhisk-go-simple/handler.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "encoding/json" 4 | import "fmt" 5 | import "os" 6 | 7 | func main() { 8 | // native actions receive one argument, the JSON object as a string 9 | arg := os.Args[1] 10 | 11 | // unmarshal the string to a JSON object 12 | var obj map[string]interface{} 13 | json.Unmarshal([]byte(arg), &obj) 14 | name, ok := obj["name"].(string) 15 | if !ok { 16 | name = "Stranger" 17 | } 18 | msg := map[string]string{"msg": ("Hello, " + name + "!")} 19 | res, _ := json.Marshal(msg) 20 | fmt.Println(string(res)) 21 | } 22 | -------------------------------------------------------------------------------- /openwhisk-go-simple/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openwhisk-go-simple", 3 | "version": "0.1.0", 4 | "description": "Example demonstrates how to setup a simple Go function with OpenWhisk.", 5 | "dependencies": { 6 | "serverless-openwhisk": ">=0.13.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /openwhisk-go-simple/serverless.yml: -------------------------------------------------------------------------------- 1 | service: go-service 2 | 3 | provider: 4 | name: openwhisk 5 | runtime: binary 6 | 7 | functions: 8 | greeting: 9 | handler: handler 10 | 11 | plugins: 12 | - serverless-openwhisk 13 | -------------------------------------------------------------------------------- /openwhisk-node-and-docker-chaining-functions/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /openwhisk-node-and-docker-chaining-functions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openwhisk-node-and-docker-chaining-functions", 3 | "version": "0.1.0", 4 | "description": "Example of chaining function calls using sequences and docker images.", 5 | "dependencies": { 6 | "serverless-openwhisk": ">=0.13.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /openwhisk-node-chaining-functions/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /openwhisk-node-chaining-functions/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function chain(parameters) { 4 | // eslint-disable-next-line global-require, import/no-extraneous-dependencies 5 | const ow = require('openwhisk')(); 6 | 7 | const invoke = (actionName, params) => ow.actions.invoke({ actionName, params, blocking: true }); 8 | return invoke('my_service-dev-split', parameters) 9 | .then(res => invoke('my_service-dev-reverse', res.response.result)) 10 | .then(res => invoke('my_service-dev-join', res.response.result)) 11 | .then(res => res.response.result); 12 | } 13 | 14 | module.exports.chain = chain; 15 | -------------------------------------------------------------------------------- /openwhisk-node-chaining-functions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openwhisk-node-chaining-functions", 3 | "version": "0.1.0", 4 | "description": "Example of chaining function calls using sequences and the sdk.", 5 | "dependencies": { 6 | "serverless-openwhisk": ">=0.13.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /openwhisk-node-chaining-functions/utils.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function split(params) { 4 | return { message: params.message.split(' ') }; 5 | } 6 | 7 | function join(params) { 8 | return { message: params.message.join(' ') }; 9 | } 10 | 11 | function reverse(params) { 12 | return { message: params.message.reverse() }; 13 | } 14 | 15 | module.exports.split = split; 16 | module.exports.join = join; 17 | module.exports.reverse = reverse; 18 | -------------------------------------------------------------------------------- /openwhisk-node-scheduled-cron/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /openwhisk-node-scheduled-cron/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function cron() { 4 | const time = new Date(); 5 | const name = '__OW_ACTION_NAME'; 6 | console.log(`Your cron function "${process.env[name]}" ran at ${time}`); 7 | } 8 | 9 | module.exports.cron = cron; 10 | -------------------------------------------------------------------------------- /openwhisk-node-scheduled-cron/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openwhisk-node-scheduled-cron", 3 | "version": "0.1.0", 4 | "description": "Example of creating a function that runs as a cron job using the serverless schedule event.", 5 | "dependencies": { 6 | "serverless-openwhisk": ">=0.13.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /openwhisk-node-simple-http-endpoint/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /openwhisk-node-simple-http-endpoint/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const moment = require('moment-timezone'); 4 | 5 | function time(params) { 6 | const timezone = params.timezone || 'Europe/London'; 7 | const timestr = moment().tz(timezone).format('HH:MM:ss'); 8 | 9 | return { payload: `The time in ${timezone} is: ${timestr}.` }; 10 | } 11 | 12 | module.exports.time = time; 13 | -------------------------------------------------------------------------------- /openwhisk-node-simple-http-endpoint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openwhisk-node-simple-http", 3 | "version": "0.1.0", 4 | "description": "Example demonstrates how to setup a simple HTTP GET endpoint with OpenWhisk.", 5 | "dependencies": { 6 | "moment-timezone": "^0.5.11", 7 | "serverless-openwhisk": ">=0.13.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /openwhisk-node-simple-http-endpoint/serverless.yml: -------------------------------------------------------------------------------- 1 | # Welcome to Serverless! 2 | # 3 | # This file is the main config file for your service. 4 | # It's very minimal at this point and uses default values. 5 | # You can always add more config options for more control. 6 | # We've included some commented out config examples here. 7 | # Just uncomment any of them to get that config option. 8 | # 9 | # For full config options, check the docs: 10 | # docs.serverless.com 11 | # 12 | # Happy Coding! 13 | 14 | service: my_service # NOTE: update this with your service name 15 | 16 | provider: 17 | name: openwhisk 18 | 19 | functions: 20 | time: 21 | handler: handler.time 22 | events: 23 | - http: GET time 24 | 25 | # remember to run npm install to download the provider plugin. 26 | plugins: 27 | - serverless-openwhisk 28 | -------------------------------------------------------------------------------- /openwhisk-node-simple/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /openwhisk-node-simple/delay.js: -------------------------------------------------------------------------------- 1 | function delay() { 2 | return new Promise(resolve => 3 | setTimeout(() => resolve({ done: true }), 2000), 4 | ); 5 | } 6 | 7 | exports.handler = delay; 8 | -------------------------------------------------------------------------------- /openwhisk-node-simple/hello_world.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function main(params) { 4 | const name = params.name || 'World'; 5 | return { payload: `Hello, ${name}!` }; 6 | } 7 | 8 | exports.handler = main; 9 | -------------------------------------------------------------------------------- /openwhisk-node-simple/left_pad.js: -------------------------------------------------------------------------------- 1 | const leftPad = require('left-pad'); 2 | 3 | function padlines(args) { 4 | const lines = args.lines || []; 5 | return { padded: lines.map(l => leftPad(l, 30, '.')) }; 6 | } 7 | 8 | exports.handler = padlines; 9 | -------------------------------------------------------------------------------- /openwhisk-node-simple/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openwhisk-node-simple", 3 | "version": "0.1.0", 4 | "description": "Simple example demonstrating OpenWhisk provider support.", 5 | "dependencies": { 6 | "left-pad": "^1.1.3", 7 | "serverless-openwhisk": ">=0.13.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /openwhisk-php-simple/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | *.pyc 3 | *.pyo 4 | -------------------------------------------------------------------------------- /openwhisk-php-simple/handler.php: -------------------------------------------------------------------------------- 1 | $greeting]; 8 | } 9 | -------------------------------------------------------------------------------- /openwhisk-php-simple/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openwhisk-php-simple", 3 | "version": "0.1.0", 4 | "description": "Example demonstrates how to setup a simple PHP function with OpenWhisk.", 5 | "dependencies": { 6 | "serverless-openwhisk": ">=0.13.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /openwhisk-php-simple/serverless.yml: -------------------------------------------------------------------------------- 1 | service: php-service 2 | 3 | provider: 4 | name: openwhisk 5 | runtime: php 6 | 7 | functions: 8 | greeting: 9 | handler: handler.greeting 10 | 11 | plugins: 12 | - serverless-openwhisk 13 | -------------------------------------------------------------------------------- /openwhisk-python-scheduled-cron/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /openwhisk-python-scheduled-cron/handler.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import os 3 | 4 | def run(params): 5 | current_time = datetime.datetime.now().time() 6 | name = os.environ['__OW_ACTION_NAME'] 7 | print("Your cron function " + name + " ran at " + str(current_time)) 8 | return {} 9 | -------------------------------------------------------------------------------- /openwhisk-python-scheduled-cron/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openwhisk-python-scheduled-cron", 3 | "version": "0.1.0", 4 | "description": "Example of creating a Python function that runs as a cron job using the serverless schedule event.", 5 | "dependencies": { 6 | "serverless-openwhisk": ">=0.13.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /openwhisk-python-scheduled-cron/serverless.yml: -------------------------------------------------------------------------------- 1 | service: python_service 2 | 3 | provider: 4 | name: openwhisk 5 | runtime: python 6 | 7 | functions: 8 | cron: 9 | handler: handler.run 10 | events: 11 | - schedule: cron(* * * * *) 12 | 13 | # remember to run npm install to download the provider plugin. 14 | plugins: 15 | - serverless-openwhisk 16 | -------------------------------------------------------------------------------- /openwhisk-python-simple-http-endpoint/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | *.pyc 3 | *.pyo 4 | -------------------------------------------------------------------------------- /openwhisk-python-simple-http-endpoint/handler.py: -------------------------------------------------------------------------------- 1 | import json 2 | import datetime 3 | 4 | def endpoint(params): 5 | current_time = datetime.datetime.now().time() 6 | name = params.get("name", "stranger") 7 | body = { 8 | "message": "Hello " + name + ", the current time is " + str(current_time) 9 | } 10 | return body 11 | -------------------------------------------------------------------------------- /openwhisk-python-simple-http-endpoint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openwhisk-python-simple-http-endpoint", 3 | "version": "0.1.0", 4 | "description": "Example demonstrates how to setup a simple HTTP GET endpoint with OpenWhisk.", 5 | "dependencies": { 6 | "serverless-openwhisk": ">=0.13.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /openwhisk-python-simple-http-endpoint/serverless.yml: -------------------------------------------------------------------------------- 1 | service: python-service 2 | 3 | provider: 4 | name: openwhisk 5 | runtime: python 6 | 7 | functions: 8 | currentTime: 9 | handler: handler.endpoint 10 | events: 11 | - http: 12 | path: ping 13 | method: get 14 | 15 | plugins: 16 | - serverless-openwhisk 17 | -------------------------------------------------------------------------------- /openwhisk-python-simple/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | *.pyc 3 | *.pyo 4 | -------------------------------------------------------------------------------- /openwhisk-python-simple/handler.py: -------------------------------------------------------------------------------- 1 | def endpoint(params): 2 | name = params.get("name", "stranger") 3 | greeting = "Hello " + name + "!" 4 | print(greeting) 5 | return {"greeting": greeting} 6 | -------------------------------------------------------------------------------- /openwhisk-python-simple/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openwhisk-python-simple", 3 | "version": "0.1.0", 4 | "description": "Example demonstrates how to setup a simple Python function with OpenWhisk.", 5 | "dependencies": { 6 | "serverless-openwhisk": ">=0.13.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /openwhisk-python-simple/serverless.yml: -------------------------------------------------------------------------------- 1 | service: python-service 2 | 3 | provider: 4 | name: openwhisk 5 | runtime: python 6 | 7 | functions: 8 | greeting: 9 | handler: handler.endpoint 10 | 11 | plugins: 12 | - serverless-openwhisk 13 | -------------------------------------------------------------------------------- /openwhisk-ruby-simple/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | *.pyc 3 | *.pyo 4 | -------------------------------------------------------------------------------- /openwhisk-ruby-simple/handler.rb: -------------------------------------------------------------------------------- 1 | def main(args) 2 | name = args["name"] || "stranger" 3 | greeting = "Hello #{name}!" 4 | puts greeting 5 | { "greeting" => greeting } 6 | end 7 | -------------------------------------------------------------------------------- /openwhisk-ruby-simple/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openwhisk-ruby-simple", 3 | "version": "0.1.0", 4 | "description": "Example demonstrates how to setup a simple Ruby function with OpenWhisk.", 5 | "dependencies": { 6 | "serverless-openwhisk": ">=0.13.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /openwhisk-ruby-simple/serverless.yml: -------------------------------------------------------------------------------- 1 | service: ruby-service 2 | 3 | provider: 4 | name: openwhisk 5 | runtime: ruby 6 | 7 | functions: 8 | greeting: 9 | handler: handler.main 10 | 11 | plugins: 12 | - serverless-openwhisk 13 | -------------------------------------------------------------------------------- /openwhisk-swift-precompiled-binaries/Package.swift: -------------------------------------------------------------------------------- 1 | import PackageDescription 2 | 3 | let package = Package( 4 | name: "Action", 5 | dependencies: [ 6 | .Package(url: "https://github.com/jthomas/OpenWhiskAction.git", majorVersion: 0) 7 | ] 8 | ) 9 | -------------------------------------------------------------------------------- /openwhisk-swift-precompiled-binaries/Sources/hello/main.swift: -------------------------------------------------------------------------------- 1 | import OpenWhiskAction 2 | 3 | func hello(args: [String:Any]) -> [String:Any] { 4 | if let name = args["name"] as? String { 5 | return [ "greeting" : "Hello \(name)!" ] 6 | } else { 7 | return [ "greeting" : "Hello stranger!" ] 8 | } 9 | } 10 | 11 | OpenWhiskAction(main: hello) 12 | -------------------------------------------------------------------------------- /openwhisk-swift-precompiled-binaries/Sources/welcome/main.swift: -------------------------------------------------------------------------------- 1 | import OpenWhiskAction 2 | 3 | func hello(args: [String:Any]) -> [String:Any] { 4 | if let name = args["name"] as? String { 5 | return [ "greeting" : "Welcome \(name)!" ] 6 | } else { 7 | return [ "greeting" : "Welcome stranger!" ] 8 | } 9 | } 10 | 11 | OpenWhiskAction(main: hello) 12 | -------------------------------------------------------------------------------- /openwhisk-swift-precompiled-binaries/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openwhisk-swift-package-with-precompiled-binaries", 3 | "version": "1.0.0", 4 | "description": "Swift packages and pre-compiled binaries on OpenWhisk.", 5 | "main": "handler.js", 6 | "scripts": { 7 | "compile": "docker run --rm -it -v $(pwd):/swift-package openwhisk/action-swift-v3.1.1 bash -e -c 'cd /swift-package && swift build -v -c release'" 8 | }, 9 | "keywords": [ 10 | "serverless", 11 | "openwhisk" 12 | ], 13 | "dependencies": { 14 | "serverless-plugin-scripts": "^1.0.2", 15 | "serverless-openwhisk": ">=0.13.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /openwhisk-swift-precompiled-binaries/serverless.yml: -------------------------------------------------------------------------------- 1 | service: swift-packages 2 | 3 | provider: 4 | name: openwhisk 5 | runtime: swift 6 | 7 | functions: 8 | hello: 9 | handler: .build/release/hello 10 | welcome: 11 | handler: .build/release/welcome 12 | 13 | custom: 14 | scripts: 15 | hooks: 16 | 'package:initialize': npm run-script compile 17 | plugins: 18 | - serverless-openwhisk 19 | - serverless-plugin-scripts 20 | -------------------------------------------------------------------------------- /openwhisk-swift-scheduled-cron/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /openwhisk-swift-scheduled-cron/handler.swift: -------------------------------------------------------------------------------- 1 | func main(args: [String:Any]) -> [String:Any] { 2 | let formatter = DateFormatter() 3 | formatter.dateFormat = "yyyy-MM-dd HH:mm:ss" 4 | let now = formatter.string(from: Date()) 5 | 6 | if let value = ProcessInfo.processInfo.environment["__OW_ACTION_NAME"] { 7 | print("Swift function (\(value)) was called @ \(now)") 8 | return [ "cron": "Swift function (\(value)) was called @ \(now)" ] 9 | } 10 | 11 | print("Swift function was called @ \(now)") 12 | return [ "cron": "Swift function was called @ \(now)" ] 13 | } 14 | 15 | -------------------------------------------------------------------------------- /openwhisk-swift-scheduled-cron/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openwhisk-swift-scheduled-cron", 3 | "version": "0.1.0", 4 | "description": "Example of creating a Swift function that runs as a cron job using the serverless schedule event.", 5 | "dependencies": { 6 | "serverless-openwhisk": ">=0.13.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /openwhisk-swift-scheduled-cron/serverless.yml: -------------------------------------------------------------------------------- 1 | service: swift_service 2 | 3 | provider: 4 | name: openwhisk 5 | runtime: swift 6 | 7 | functions: 8 | cron: 9 | handler: handler.main 10 | events: 11 | - schedule: cron(* * * * *) 12 | 13 | # remember to run npm install to download the provider plugin. 14 | plugins: 15 | - serverless-openwhisk 16 | -------------------------------------------------------------------------------- /openwhisk-swift-simple-http-endpoint/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | *.pyc 3 | *.pyo 4 | -------------------------------------------------------------------------------- /openwhisk-swift-simple-http-endpoint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openwhisk-swift-simple-http-endpoint", 3 | "version": "0.1.0", 4 | "description": "Example demonstrates how to setup a simple HTTP endpoint using Swift function with OpenWhisk.", 5 | "dependencies": { 6 | "serverless-openwhisk": ">=0.13.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /openwhisk-swift-simple-http-endpoint/ping.swift: -------------------------------------------------------------------------------- 1 | func main(args: [String:Any]) -> [String:Any] { 2 | let formatter = DateFormatter() 3 | formatter.dateFormat = "yyyy-MM-dd HH:mm:ss" 4 | let now = formatter.string(from: Date()) 5 | 6 | if let name = args["name"] as? String { 7 | return [ "greeting" : "Hello \(name)! The time is \(now)" ] 8 | } else { 9 | return [ "greeting" : "Hello stranger! The time is \(now)" ] 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /openwhisk-swift-simple-http-endpoint/serverless.yml: -------------------------------------------------------------------------------- 1 | service: swift-service 2 | 3 | provider: 4 | name: openwhisk 5 | runtime: swift 6 | 7 | functions: 8 | ping: 9 | handler: ping.main 10 | events: 11 | - http: 12 | path: ping 13 | method: get 14 | 15 | 16 | plugins: 17 | - serverless-openwhisk 18 | -------------------------------------------------------------------------------- /openwhisk-swift-simple/.gitignore: -------------------------------------------------------------------------------- 1 | .serverless 2 | *.pyc 3 | *.pyo 4 | -------------------------------------------------------------------------------- /openwhisk-swift-simple/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openwhisk-swift-simple", 3 | "version": "0.1.0", 4 | "description": "Example demonstrates how to setup a simple Swift function with OpenWhisk.", 5 | "dependencies": { 6 | "serverless-openwhisk": ">=0.13.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /openwhisk-swift-simple/ping.swift: -------------------------------------------------------------------------------- 1 | func main(args: [String:Any]) -> [String:Any] { 2 | let formatter = DateFormatter() 3 | formatter.dateFormat = "yyyy-MM-dd HH:mm:ss" 4 | let now = formatter.string(from: Date()) 5 | 6 | if let name = args["name"] as? String { 7 | return [ "greeting" : "Hello \(name)! The time is \(now)" ] 8 | } else { 9 | return [ "greeting" : "Hello stranger! The time is \(now)" ] 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /openwhisk-swift-simple/serverless.yml: -------------------------------------------------------------------------------- 1 | service: swift-service 2 | 3 | provider: 4 | name: openwhisk 5 | runtime: swift 6 | 7 | functions: 8 | ping: 9 | handler: ping.main 10 | 11 | plugins: 12 | - serverless-openwhisk 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "serverless-examples", 3 | "version": "0.0.0", 4 | "description": "A compilation of several examples and boilerplates", 5 | "scripts": { 6 | "lint": "eslint .", 7 | "docs": "node generate-readme.js", 8 | "validate": "node validate.js" 9 | }, 10 | "license": "MIT", 11 | "dependencies": { 12 | "eslint": "^5.15.3", 13 | "eslint-config-airbnb-base": "^10.0.1", 14 | "eslint-plugin-import": "^2.16.0", 15 | "gray-matter": "^4.0.2", 16 | "markdown-magic": "^0.1.25" 17 | }, 18 | "devDependencies": {} 19 | } 20 | -------------------------------------------------------------------------------- /twilio-node-forward-call/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .serverless 3 | -------------------------------------------------------------------------------- /twilio-node-forward-call/forward-call.js: -------------------------------------------------------------------------------- 1 | exports.handler = function(context, event, callback) { 2 | let twiml = new Twilio.twiml.VoiceResponse() 3 | twiml.dial(context.MY_PHONE_NUMBER); 4 | callback(null, twiml); 5 | }; -------------------------------------------------------------------------------- /twilio-node-forward-call/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "twilio.node-forward-call", 3 | "version": "1.0.-", 4 | "description": "Example demonstrating Twilio Runtime support with an endpoint that returns TwiML to forward a phone call", 5 | "dependencies": {}, 6 | "devDependencies": { 7 | "@twilio-labs/serverless-twilio-runtime": "^1.0.5" 8 | } 9 | } 10 | --------------------------------------------------------------------------------