【发布时间】:2018-07-23 22:10:25
【问题描述】:
我使用无服务器框架并希望部署 API Gateway HTTP 代理,但我没有与 API Gateway 连接的 Lambda 函数。
我在互联网上找到了这个,但是这个例子需要一个连接到 API 网关的 lambda 函数
# ProxyResource:
# Type: AWS::ApiGateway::Resource
# Properties:
# ParentId:
# Fn::GetAtt:
# - ApiGatewayRestApi # our default Rest API logical ID
# - RootResourceId
# PathPart: serverless # the endpoint in your API that is set as proxy
# RestApiId:
# Ref: ApiGatewayRestApi
# ProxyMethod:
# Type: AWS::ApiGateway::Method
# Properties:
# ResourceId:
# Ref: ProxyResource
# RestApiId:
# Ref: ApiGatewayRestApi
# HttpMethod: GET # the method of your proxy. Is it GET or POST or ... ?
# MethodResponses:
# - StatusCode: 200
# Integration:
# IntegrationHttpMethod: POST
# Type: HTTP
# Uri: http://serverless.com # the URL you want to set a proxy to
# IntegrationResponses:
# - StatusCode: 200
如果我部署这个我得到了错误:
The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [ApiGatewayRestApi] in the Resources block of the template
是否可以只部署一个 API Gateway HTTP 代理?
谢谢
【问题讨论】:
-
我能问一下你想要达到什么目的吗?
-
我有一个正在运行的 AppSync 服务,但该服务需要身份验证(最低要求是 API 密钥)。我不乐意总是将 ApiKey 传递给我的应用程序,并希望创建一个 API Gateway 代理,将 API 密钥传递给 AppSync。这样我就不需要每年都更改 ApiKey(例如在移动应用中)。
标签: amazon-web-services serverless-framework serverless