Serverless Framework 101

安裝 Serverless Framework

Prerequisites

$ npm install -g serverless

創建一個 Service


$ serverless

? What do you want to make?
  AWS - Node.js - Starter
  AWS - Node.js - HTTP API
  AWS - Node.js - Scheduled Task
  AWS - Node.js - SQS Worker
  AWS - Node.js - Express API
  AWS - Node.js - Express API with DynamoDB 
  AWS - Python - Starter
> AWS - Python - HTTP API
  AWS - Python - Scheduled Task
  AWS - Python - SQS Worker
  AWS - Python - Flask API
  AWS - Python - Flask API with DynamoDB    
  Other

輸入指令後透過方向鍵選取你要的 Template,本文將已 AWS - Python HTTP API 示範

如果這些模板沒有你滿意的,可以到 serverless/examples 找你要的模板,然後指令輸入 serverless --template-url=https://github.com/serverless/examples/tree/v3/...

? What do you want to call this project? serverless-framework-101

✔ Project successfully created in serverless-framework-101 folder

? Register or Login to Serverless Framework Yes      
Logging into the Serverless Framework via the browser
If your browser does not open automatically, please open this URL:       
<https://app.serverless.com?client=cli&transactionId=x6r7NmzVa-ExeVdCyQZV2>

✔ You are now logged into the Serverless Framework

✔ Your project is ready to be deployed to Serverless Dashboard (org: "shiunchiu", app: "serverless-framework-101")

進入你的工作目錄,然後開啟 VSCode