fre*_*ckd 5 aws-cloudformation amazon-gateway
无法使用 Cloudformation 为 Websocket 路由集成请求定义集成类型“VPC 链接”。
我们不使用无服务器,但现有的微服务提供 websocket 功能。这些微服务在专用网络上运行,只能通过与运行它们的 EKS 集群的 VPC 链接来使用。
所有与 AWS API 网关/websocket 相关的在线 Cloudformation 示例都使用无服务器集成。
我可以使用 AWS 控制台手动配置集成类型“VPC 链接”,但似乎不支持使用 Cloudformation 执行此操作。或者至少根本不清楚如何实现这一目标。
Cloudformation 文档还明确指出,对于 AWS::APIGatewayV2::Integration.ConnectionType,唯一可用的类型是“INTERNET”,而不是“VPC_LINK”。
任何人都知道这是否可以实现,如果不能,我还有哪些其他选项可以实现自动化?
基础设施是使用 Terraform 设置的,由于缺乏对 API 网关/websockets 的支持,我已经需要“回退”到 CloudFormation,但 CloudFormation 似乎还不支持所有内容。
恐怕我也有类似的问题。我无法使用 VPC Link 创建与私有 ALB(http 集成)的 API Gateway Websocket API 集成。
我可以使用 cloudFormation 成功地将 Api 网关 HTTP API 与使用 VPC 链接的内部 ALB 集成(按照此 )。
但是,尽管AWS::APIGatewayV2::Integration.ConnectionType支持INTERNET和VPC_LINK根据文档,它似乎不起作用,并且云形成堆栈失败并出现以下错误:
VpcLink V2 are not supported for WEBSOCKET Apis. Only Http Apis are supported. (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException
Run Code Online (Sandbox Code Playgroud)
关于我如何尝试的云形成示例
websocketApiGateway:
Type: AWS::ApiGatewayV2::Api
Properties:
Name: websocket-gateway
Description: Api Gateway for websocket
ProtocolType: WEBSOCKET
RouteSelectionExpression: $request.body.action
connectRoute:
Type: AWS::ApiGatewayV2::Route
Properties:
ApiId: !Ref websocketApiGateway
RouteKey: $connect
AuthorizationType: NONE
OperationName: ConnectRoute
RouteResponseSelectionExpression: $default
Target: !Join
- /
- - integrations
- !Ref connectIntegration
connectIntegration:
Type: AWS::ApiGatewayV2::Integration
Properties:
ApiId: !Ref websocketApiGateway
Description: Websocket $connect integration
IntegrationType: HTTP_PROXY
IntegrationMethod: ANY
ConnectionType: VPC_LINK
ConnectionId: !Ref privateLink
IntegrationUri: # with VPC_LINK I can't use a well formed url, it's necessary to use the ALB's ARN
Fn::ImportValue: alb-http-listener-id
RequestParameters:
"integration.request.header.domainName": "context.domainName"
"integration.request.header.stage": "context.stage"
"integration.request.header.connectionId": "context.connectionId"
PayloadFormatVersion: 1.0
privateLink:
Type: AWS::ApiGatewayV2::VpcLink
Properties:
Name: private-link
SecurityGroupIds:
- !Ref securityGroup
SubnetIds:
- !Ref privateNetworkA
- !Ref privateNetworkB
- !Ref privateNetworkC
Run Code Online (Sandbox Code Playgroud)
如果有人有更多信息,请发布。缺乏支持和混乱的文档是不幸的。
| 归档时间: |
|
| 查看次数: |
1831 次 |
| 最近记录: |