AWS Deployment through Serverless - K.Merino
AWS Deployment through Serverless - K.Merino
Amazon Web Services
AWS Deployment through Serverless - K.Merino
AWS Deployment through Serverless - K.Merino
BARF
AWS Deployment through Serverless - K.Merino
AWS Deployment through Serverless - K.Merino
Use of variables for custom deloyments
service: todos-service
custom: ${file(../config/${opt:stage, self:provider.stage}.yml)}
service: "my-serverless-app"
region: "us-west-2"
stage: "dev"
todosBucket: "todos-bucket-dev"
userBucket: "user-bucket-dev"
service: "my-serverless-app"
region: "us-east-1"
stage: "test"
todosBucket: "todos-bucket-test"
userBucket: "user-bucket-test"
Deploy to east region to a test environment
Deploy to west region to a dev environment
AWS Deployment through Serverless - K.Merino
AWS Deployment through Serverless - K.Merino
The yaml file
service: todos-service
custom: ${file(../config/${opt:stage, self:provider.stage}.yml)}
provider:
name: aws
runtime: nodejs4.3
region: ${self:custom.region}
stage: dev
iamRoleStatements:
- Effect: "Allow"
Action:
- "lambda:InvokeFunction"
Resource: ["*"]
- Effect: "Allow"
Action:
- execute-api:InvokeFunction
Resource: "arn:aws:execute-api:${self:custom.region}:*:*"
functions:
GetTodos:
handler: handler.getTodos
events:
- http:
path: todos/create
method: get
cors: true
resources:
Resources:
TodosBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.todosBucket}
Easy integration with AWS Lambda
functions:
GetTodos:
handler: handler.getTodos
events:
- http:
path: todos/create
method: get
cors: true
module.exports.getTodos = (event, context, callback) => {
const response = {
statusCode: 200,
headers: {
"Access-Control-Allow-Origin" : "*",
"Access-Control-Allow-Credentials" : true
},
body: JSON.stringify({
message: 'Here are your todos',
input: event,
}),
};
callback(null, response);
};
handler.js
yaml file
AWS Deployment through Serverless - K.Merino
AWS Deployment through Serverless - K.Merino
@ladycornfish
AWS Deployment through Serverless - K.Merino