Lambda
API Gateway
S3
DynamoDB
Cognito
SNS
Go
2014
Lambda
Serverless Framework
2015
API Gateway
2016
npm i -g serverless
serverless create --template aws-nodejs
serverless deploy
serverless logs
serverless removenpm i -g serverless
sls create --template aws-nodejs --path example1
service:
name: myAPI
frameworkVersion: ">=1.0.0 <2.0.0"
provider:
name: aws
runtime: nodejs6.10
stage: dev
region: us-east-1
memorySize: 512
timeout: 10environment:
STAGE: ${self:provider.stage}
VEHICLES_TABLE: vehicles-${self:provider.stage}
LOCATIONS_TABLE: locations-${self:provider.stage}
STATES_TABLE: states-${self:provider.stage}
SKUS_TABLE: skus-${self:provider.stage}
MAKES_TABLE: makes-${self:provider.stage}
MODELS_TABLE: models-${self:provider.stage}functions:
locations:
handler: lambdas/locations.locations
description: locations lambda
events:
- http:
path: api/locations
method: get
cors: true
- http:
path: api/locations
request: ${self:custom.standardRequest}
integration: lambda
method: post
cors: trueresources:
Resources:
LocationsTable:
Type: AWS::DynamoDB::Table
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.LOCATIONS_TABLE}sls logs -f hello -teg Librato