Forked from maatthc/aws-websockets-api-gw-mock.yaml
Created
February 12, 2021 10:27
-
-
Save veve90/54629c0fc735b79cbbd3a09acdcb1fc1 to your computer and use it in GitHub Desktop.
Revisions
-
maatthc revised this gist
Nov 12, 2019 . 1 changed file with 34 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,40 @@ AWSTemplateFormatVersion: '2010-09-09' Description: | AWS CloudFormation template for Mock WebSocket API Gateway. When deploying this stack please remember to check the option: - I acknowledge that AWS CloudFormation might create IAM resources. This template can help you to solve issues like: - CloudWatch Logs role ARN must be set in account settings to enable logging - Execution failed due to configuration error: statusCode should be an integer which defined in request template - This custom domain name cannot map to WEBSOCKET protocol APIs - Error during WebSocket handshake: Unexpected response code: 500 Resources: ApiGwAccountConfig: Type: "AWS::ApiGateway::Account" Properties: CloudWatchRoleArn: !GetAtt "ApiGatewayLoggingRole.Arn" ApiGatewayLoggingRole: Type: "AWS::IAM::Role" Properties: AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: Allow Principal: Service: - "apigateway.amazonaws.com" Action: "sts:AssumeRole" Path: "/" ManagedPolicyArns: - !Sub "arn:${AWS::Partition}:iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs" WebSocketMock: Type: AWS::ApiGatewayV2::Api Properties: Name: WebSocketMock ProtocolType: WEBSOCKET RouteSelectionExpression: "$request.body.message" Description: "Mock WebSocket API Gateway." ConnectRoute: Type: AWS::ApiGatewayV2::Route @@ -82,7 +108,7 @@ Resources: IntegrationId: !Ref DisconnectInteg IntegrationResponseKey: '$default' ResponseTemplates: "200" : '{"statusCode" : 200}' DisconnectRouteResponse: Type: AWS::ApiGatewayV2::RouteResponse @@ -146,4 +172,8 @@ Resources: StageName: LATEST Description: One and only Stage DeploymentId: !Ref Deployment ApiId: !Ref WebSocketMock DefaultRouteSettings: DetailedMetricsEnabled: true LoggingLevel: INFO
-
maatthc revised this gist
Nov 11, 2019 . 1 changed file with 0 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +0,0 @@ -
maatthc revised this gist
Nov 11, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,4 +4,4 @@  https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=WsApiGw&templateURL=https://gist.github.com/maatthc/9d2dfe0448733f0ee1624d658fbac80f/raw/d8360e59a9322ec53e0270bec08cbd978e6aaeb9/aws-websockets-api-gw-mock.yaml -
maatthc revised this gist
Nov 11, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,4 +4,4 @@  https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=WsApiGw&templateURL= -
maatthc revised this gist
Nov 11, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,6 @@ ## Click here to deploy  https://console.aws.amazon.com/cloudformation/home?region=region#/stacks/new?stackName=stack_name&templateURL=template_location -
maatthc revised this gist
Nov 11, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ # Basic WebSocket mock in AWS ApiGateway using CloudFormation in AWS ## Click here to deploy  https://console.aws.amazon.com/cloudformation/home?region=region#/stacks/new?stackName=stack_name&templateURL=template_location -
maatthc revised this gist
Nov 11, 2019 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,7 @@ # Basic WebSocket mock in AWS ApiGateway using CloudFormation in AWS # Click here to deploy (https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png) https://console.aws.amazon.com/cloudformation/home?region=region#/stacks/new?stackName=stack_name&templateURL=template_location -
maatthc revised this gist
Nov 11, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ # Basic WebSocket mock in AWS ApiGateway using CloudFormation in AWS -
maatthc created this gist
Nov 11, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,149 @@ AWSTemplateFormatVersion: '2010-09-09' Description: AWS CloudFormation template for WebSocket API Gateway Mock Resources: WebSocketMock: Type: AWS::ApiGatewayV2::Api Properties: Name: WebSocketMock ProtocolType: WEBSOCKET RouteSelectionExpression: "$request.body.message" Description: "WebSocket API Gateway" ConnectRoute: Type: AWS::ApiGatewayV2::Route Properties: ApiId: !Ref WebSocketMock RouteKey: $connect RouteResponseSelectionExpression: '$default' AuthorizationType: NONE ApiKeyRequired: false OperationName: ConnectRoute Target: !Join - '/' - - 'integrations' - !Ref ConnectInteg ConnectInteg: Type: AWS::ApiGatewayV2::Integration Properties: ApiId: !Ref WebSocketMock Description: Connect Integration IntegrationType: MOCK RequestTemplates: "200" : '{"statusCode" : 200}' TemplateSelectionExpression: '200' PassthroughBehavior: 'WHEN_NO_MATCH' ConnectIntegResp: Type: AWS::ApiGatewayV2::IntegrationResponse Properties: ApiId: !Ref WebSocketMock IntegrationId: !Ref ConnectInteg IntegrationResponseKey: '$default' ResponseTemplates: "200" : '{"statusCode" : 200}' ConnectRouteResponse: Type: AWS::ApiGatewayV2::RouteResponse Properties: RouteId: !Ref ConnectRoute ApiId: !Ref WebSocketMock RouteResponseKey: $default DisconnectRoute: Type: AWS::ApiGatewayV2::Route Properties: ApiId: !Ref WebSocketMock RouteKey: $disconnect RouteResponseSelectionExpression: '$default' AuthorizationType: NONE OperationName: DisconnectRoute Target: !Join - '/' - - 'integrations' - !Ref DisconnectInteg DisconnectInteg: Type: AWS::ApiGatewayV2::Integration Properties: ApiId: !Ref WebSocketMock Description: Disconnect Integration IntegrationType: MOCK RequestTemplates: "200" : '{"statusCode" : 200}' TemplateSelectionExpression: '200' PassthroughBehavior: 'WHEN_NO_MATCH' DisconnectIntegResp: Type: AWS::ApiGatewayV2::IntegrationResponse Properties: ApiId: !Ref WebSocketMock IntegrationId: !Ref DisconnectInteg IntegrationResponseKey: '$default' ResponseTemplates: "application/json" : '{"statusCode" : 200}' DisconnectRouteResponse: Type: AWS::ApiGatewayV2::RouteResponse Properties: RouteId: !Ref DisconnectRoute ApiId: !Ref WebSocketMock RouteResponseKey: $default DefaultRoute: Type: AWS::ApiGatewayV2::Route Properties: ApiId: !Ref WebSocketMock RouteKey: $default RouteResponseSelectionExpression: '$default' AuthorizationType: NONE OperationName: DefaultRoute Target: !Join - '/' - - 'integrations' - !Ref DefaultInteg DefaultInteg: Type: AWS::ApiGatewayV2::Integration Properties: ApiId: !Ref WebSocketMock Description: Default Integration IntegrationType: MOCK RequestTemplates: "200" : '{"statusCode" : 200}' TemplateSelectionExpression: '200' DefaultIntegResp: Type: AWS::ApiGatewayV2::IntegrationResponse Properties: ApiId: !Ref WebSocketMock IntegrationId: !Ref DefaultInteg IntegrationResponseKey: $default ResponseTemplates: "200" : '{"statusCode" : 200, "connectionId" : "$context.connectionId"}' TemplateSelectionExpression: '200' DefaultRouteResponse: Type: AWS::ApiGatewayV2::RouteResponse Properties: RouteId: !Ref DefaultRoute ApiId: !Ref WebSocketMock RouteResponseKey: $default Deployment: Type: AWS::ApiGatewayV2::Deployment DependsOn: - ConnectRoute - DisconnectRoute - DefaultRoute Properties: ApiId: !Ref WebSocketMock Stage: Type: AWS::ApiGatewayV2::Stage Properties: StageName: LATEST Description: One and only Stage DeploymentId: !Ref Deployment ApiId: !Ref WebSocketMock