【问题标题】:How can I ref API gateway endpoint in serverless?如何在无服务器中引用 API 网关端点?
【发布时间】:2020-10-30 03:24:39
【问题描述】:

我使用serverless.yml 作为基础设施。框架。我创建了一个带有 API 网关的 lambda,如下代码:

functions:
  create:
    handler: posts.create
    events:
      - http:
          path: posts/create
          method: post
          authorizer: xxx:xxx:Lambda-Name

它将为 API 网关生成一个端点。但是如何在 yml 文件的其他位置引用此端点?

【问题讨论】:

  • 它并没有真正的帮助,因为它依赖于现有的 API 网关资源,即 ApiGatewayRestApi。但是在我的 serverless.yml 文件中,没有这样的资源。它是由无服务器自动生成的。

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


【解决方案1】:

Ref: ApiGatewayRestApi - ApiGatewayRestApi 是默认的 Rest API 逻辑 ID。

How do I get/reference API gateway restAPI id in serverless.yml?

custom:
    webServiceEndpoint:
        Fn::Join:
          - ''
          - - 'https://'
            - Ref: ApiGatewayRestApi
            - '.execute-api.'
            - Ref: AWS::Region
            - '.amazonaws.com/'
            - ${self:provider.stage}

【讨论】:

猜你喜欢
  • 2019-09-29
  • 2022-06-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-10-28
  • 2015-10-03
  • 2020-11-01
  • 2023-01-04
相关资源
最近更新 更多