As the title says, the fastest deployment. U
se .js 12.x runtime.
Prerequisites
Serverless Framework
Tools for configuring and deploying serverless applications.
Serverless: Zero-Friction Serverless Apps On AWS Lambda & Beyond.
Easily build auto-scaling, low-overhead applications on AWS Lambda, API Gateway, DynamoDB, and other managed services wi...
Prepare
$ npm install -g serverless
implementation
1. Create a project
$ serverless create --template aws-nodejs --name my-project --path my-project
...
$ cd my-project
$ ls
handler.js serverless.yml
When you create a project, two files are generated.
The contents of each file are like this.
'use strict';
module.exports.hello = async event => {
return {
statusCode: 200,
body: JSON.stringify(
{
message: 'Go Serverless v1.0! Your function executed successfully!',
input: event,
},
null,
2
),
};
(Comment part omitted)
};
# (comments omitted)
service: my-project
# (comments omitted)
provider:
name: aws
runtime: nodejs12.x
# (comments omitted)
functions:
hello:
handler: handler.hello
# (comments omitted)
2. Implement an API that returns the simplest JSON
If the .js just ret
urns what's written in the instructions, you can implement serverles
s.yml with just a little fiddle.
(omitted)
provider:
name: aws
runtime: nodejs12.x
+ region: ap-northeast-1
+ profile: test
(omitted)
functions:
hello:
handler: handler.hello
+ events:
+ - http: GET hello
(omitted)
Note: Profile for deploying to AWS. Choose from ~/.aws/creditals to
use. (test this time)
For credital, see Formulas and more:
の設定 AWS CLI - AWS Command Line Interface
が とやり取り AWS CLI するために使用する設定を設定します AWS。
3. Deploy
$ serverless deploy
(omitted)
api keys:
None
endpoints:
GET - https:// (random).execute-api.ap-northeast-1.amazonaws.com/dev/hello
(omitted)
Now it's complete. https:// you access the execute-api.ap-northeast-1.amazonaws.com/dev/hello (random). .js the
contents of the handler file
are returned in JSON format.
Summary
Super easy!