如何从 aws 上的无服务器框架输出资源路径?

时间:2021-06-18 19:46:38

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

如何将资源路径/URL 输出到 cloudformation 输出?

例如,我有一个 lambda 正在侦听路径 /hello 上的 http 事件,并且我希望 cloudformation 输出值为 https://kjkjwerwer.execute-api.eu-west-1.amazonaws.com/test/hello 的变量

默认情况下,无服务器框架输出 ServiceEndpoint,但是,我想要每个函数的完整端点

1 个答案:

答案 0 :(得分:2)

您可以在 resources 部分输出您想要的任何内容。 您可以使用所有相同的模板变量(如 !Ref${self:custom.myEndpointName}!Join)来清理它:

resources:
  Outputs:
    MyEndpointName:
      Description: HTTP Endpoint for MyEndpoint lambda
      Value: ${self:custom.myEndpointName} // Or some other templated/hardcoded string