【问题标题】:Lambda Function Aliases with the Serverless Framework?无服务器框架的 Lambda 函数别名?
【发布时间】:2021-03-10 00:43:58
【问题描述】:

是否可以在无服务器框架中使用 Lambda 函数别名 (https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html)?如果是这样,有没有人举例说明如何做到这一点?

更新:

我在 SAM 中找到了它:

AutoPublishAlias:通过添加此属性并指定别名,AWS SAM:

根据对 Lambda 函数的 Amazon S3 URI 的更改检测何时部署新代码。

使用最新代码创建并发布该函数的更新版本。

使用您提供的名称创建一个别名(除非别名已经存在),并指向 Lambda 函数的更新版本。函数调用应该使用别名限定符来利用这一点。如果您不熟悉 Lambda 函数版本控制和别名,请参阅 AWS Lambda 函数版本控制和别名。

https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/automating-updates-to-serverless-apps.html

有没有办法在无服务器框架中做到这一点?

【问题讨论】:

    标签: amazon-web-services aws-lambda serverless-framework


    【解决方案1】:

    我能够使用名为 serverless-plugin-canary-deployments: https://github.com/davidgf/serverless-plugin-canary-deployments 的插件来完成此操作

    我是从这篇博文中找到的:https://www.serverless.com/blog/manage-canary-deployments-lambda-functions-serverless-framework

    例子:

    service: sls-canary-example
    
    provider:
      name: aws
      runtime: nodejs6.10
    
    plugins:
      - serverless-plugin-canary-deployments
    
    functions:
      hello:
        handler: handler.hello
        events:
          - http: get hello
        deploymentSettings:
          type: Linear10PercentEvery1Minute
          alias: Live
    

    Serverless.com 向我确认没有本地方法可以做到这一点,但我认为这个插件可以满足我的需要,但需要注意的是 deploymentSettings 没有通过配置验证,所以你会得到部署警告。

    【讨论】:

      猜你喜欢
      • 2019-07-23
      • 2021-10-07
      • 2023-03-16
      • 2020-07-25
      • 1970-01-01
      • 2018-09-17
      • 1970-01-01
      • 2022-12-09
      • 2019-01-04
      相关资源
      最近更新 更多