zoukankan      html  css  js  c++  java
  • [Serverless CLI + AWS] Get started with Serverless and AWS lambda

    Serverless AWS lambda

    Config serverless with aws

    serverless config credentials --provider aws --key <ACCESS_KEY_AWS> --secret <SECRET_KEY_AWS>
    

    Init project

    serverless create --template aws-nodejs --name cake-ordering-system
    

    Define how to trigger lambda in serverless.yml

    for example:

    functions:
      createOrder:
        handler: handler.createOrder
        # trigger for lambda
        events:
          # http: stands for APIGateWay
          - http:
              path: /order
              method: post
    

    Hanlder

    In handler.js:

    "use strict";
    
    module.exports.createOrder = async (event) => {
      return {
        statusCode: 200,
        body: JSON.stringify({
          message: "Create Order",
          input: event,
        }),
      };
    };
    

    Deploy

    sls deploy
    

    Logs

    sls logs -f <FUNCTION_NAME>
    ## sls logs -f notifyExternalParties
    

    Clean up

    sls remove
    
  • 相关阅读:
    JSONP
    函数式编程
    Cookie
    IE userData
    Web Storage
    前端学PHP之会话Session
    数据结构之归并排序
    数据结构之冒泡排序
    数据结构之插入排序
    数据结构之选择排序
  • 原文地址:https://www.cnblogs.com/Answer1215/p/14443931.html
Copyright © 2011-2022 走看看