API网关HTTP代理与无服务器离线的集成(非Lambda代理) [英] API Gateway HTTP Proxy integration with serverless-offline (NOT Lambda Proxy)
问题描述
我正在尝试使用无服务器离线在本地开发/模拟我的API网关.我的API网关自由使用
I am trying to use serverless-offline to develop / simulate my API Gateway locally. My API gateway makes liberal use of the HTTP proxy integrations. The production Resource looks like this:
我已经基于一些文档和讨论创建了无服务器脱机配置,其中说有可能使用Cloud Formation配置来定义HTTP代理集成:
I have created a serverless-offline configuration based on a few documents and discussion which say that it is possible to define an HTTP Proxy integration using Cloud Formation configuration:
- httpProxyWithApiGateway.md -使用无服务器框架在API网关上设置HTTP代理./li>
- 在API网关上设置HTTP代理(无服务器官方文档:API网关)
- httpProxyWithApiGateway.md - Setting an HTTP Proxy on API Gateway by using Serverless framework.
- Setting an HTTP Proxy on API Gateway (official Serverless docs: API Gateway)
出于我的目的,我已经修改了上面的两个配置示例,请参见下文.
I have adapted the above two configuration examples for my purposes, see below.
有什么提示,我在这里可能做错了什么?
Have any tips, for what I might be doing wrong here?
plugins:
- serverless-offline
service: company-apig
provider:
name: aws
stage: dev
runtime: python2.7
resources:
Resources:
# Parent APIG RestApi
ApiGatewayRestApi:
Type: AWS::ApiGateway::RestApi
Properties:
Name: company-apig
Description: 'The main entry point of the APIG'
# Resource /endpoint
EndpointResource:
Type: AWS::ApiGateway::Resource
Properties:
ParentId:
Fn::GetAtt:
- ApiGatewayRestApi
- RootResourceId
PathPart: 'endpoint'
RestApiId:
Ref: ApiGatewayRestApi
# Resource /endpoint/{proxy+}
EndpointProxyPath:
Type: AWS::ApiGateway::Resource
Properties:
ParentId:
Ref: EndpointResource
PathPart: '{proxy+}'
RestApiId:
Ref: ApiGatewayRestApi
# Method ANY /endpoint/{proxy+}
EndpointProxyAnyMethod:
Type: AWS::ApiGateway::Method
Properties:
AuthorizationType: NONE
HttpMethod: ANY
Integration:
IntegrationHttpMethod: ANY
Type: HTTP_PROXY
Uri: http://endpoint.company.cool/{proxy}
PassthroughBehavior: WHEN_NO_MATCH
MethodResponses:
- StatusCode: 200
ResourceId:
Ref: EndpointProxyPath
RestApiId:
Ref: ApiGatewayRestApi
对于以上配置,我得到此输出.显然,该配置根本没有注册任何路由.
For the above configuration, I get this output. Apparently, the configuration registers no routes at all.
{
"statusCode":404,
"error":"Serverless-offline: route not found.",
"currentRoute":"get - /endpoint/ping",
"existingRoutes":[]
}