如何在无服务器中引用API网关端点



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

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

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

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

如何在serverless.yml中获取/引用API网关restAPI id?

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

对于可以使用的套接字端点。还要在.serverless中检查您的云信息,以重新检查这些名称。

socketServiceEndpoint:
Fn::Join:
- ""
- - "wss://"
- Ref: WebsocketsApi 
- ".execute-api."
- Ref: AWS::Region
- ".amazonaws.com/"
- ${self:provider.stage}

最新更新