AWS는 최근 websocket API 게이트웨이 템플릿을위한 Cloudformation 지원을 출시했습니다 . 작업 예제를 배포했지만 프록시 통합 응답을 켜는 방법을 알아낼 수 없습니다 (콘솔에서 수행되는 방법은 스크린 샷 참조). 누구든지 람다 프록시 통합에 대한 기본 통합 응답을 켜는 데 사용할 수있는 cloudFormation 설정을 알고 있습니까?
아래 단계를 시도하십시오
1- Route에 RouteResponseSelectionExpression을 $ default로 추가합니다 (현재는 하나만 지원됨).
2- 양방향이되도록하려는 모든 경로에 대해 Route에 대한 RouteResponse 생성
참고 :-RouteResponseKey : $ default // 기본값이어야합니다.
3- ConnectIntegResponse 추가 (선택 사항)
아래는 테스트 된 CF 스 니펫입니다. 자유롭게 사용하세요.
##########Socket API###############
webSocket:
Type: AWS::ApiGatewayV2::Api
Properties:
Name: WebSocket
ProtocolType: WEBSOCKET
RouteSelectionExpression: "$request.body.action"
ConnectRoute:
Type: AWS::ApiGatewayV2::Route
Properties:
ApiId: !Ref webSocket
RouteKey: $connect
AuthorizationType: NONE
OperationName: ConnectRoute
RouteResponseSelectionExpression: $default # add this
Target: !Join
- '/'
- - 'integrations'
- !Ref ConnectInteg
ConnectInteg:
Type: AWS::ApiGatewayV2::Integration
Properties:
ApiId: !Ref webSocket
Description: Connect Integration
IntegrationType: AWS_PROXY
IntegrationUri:
Fn::Sub:
arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${restAndSocketLambda.Arn}/invocations
ConnectRouteResponse: # Add this
Type: 'AWS::ApiGatewayV2::RouteResponse'
Properties:
RouteId: !Ref ConnectRoute
ApiId: !Ref webSocket
RouteResponseKey: $default
ConnectIntegResponse: # Add this(if required)
Type: 'AWS::ApiGatewayV2::IntegrationResponse'
Properties:
IntegrationId: !Ref ConnectInteg
IntegrationResponseKey: /201/
ApiId: !Ref webSocket
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다