Skip to content

Instantly share code, notes, and snippets.

@bjorg
Created July 7, 2020 16:34
Show Gist options
  • Save bjorg/f885da7f5cfe04ab38e2b89f069e1390 to your computer and use it in GitHub Desktop.
Save bjorg/f885da7f5cfe04ab38e2b89f069e1390 to your computer and use it in GitHub Desktop.
I think I'm running into a CloudFormation bug with AWS::ApiGatewayV2::Stage RouteSettings. The following template fails with this error message when RouteSettings is included, otherwise it succeeds. Am I doing it wrong?
AWSTemplateFormatVersion: '2010-09-09'
Resources:
ModuleWebSocketStage:
Type: AWS::ApiGatewayV2::Stage
Properties:
ApiId: !Ref ModuleWebSocket
StageName: LATEST
DeploymentId: !Ref ModuleWebSocketDeployment7DE845992A5611C1BEBFBCD7A01DB8B8
# NOTE: the following properties cause the stack creation to fail
# ERROR:
# Property validation failure: [Value of property {/RouteSettings/LoggingLevel} does not match type {Object}, Value of property {/RouteSettings/DataTraceEnabled} does not match type {Object}, Value of property {/RouteSettings/DetailedMetricsEnabled} does not match type {Object}]
# Documentation: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-stage-routesettings.html
RouteSettings:
DataTraceEnabled: true
DetailedMetricsEnabled: true
LoggingLevel: INFO
ModuleWebSocket:
Type: AWS::ApiGatewayV2::Api
Properties:
ProtocolType: WEBSOCKET
Name: !Sub "${AWS::StackName} Module WebSocket"
RouteSelectionExpression: $request.body.action
ModuleWebSocketDeployment7DE845992A5611C1BEBFBCD7A01DB8B8:
Type: AWS::ApiGatewayV2::Deployment
Properties:
ApiId: !Ref ModuleWebSocket
DependsOn:
- MessageFunctionDefaultRoute
- MessageFunctionWebSocketIntegration
MessageFunctionDefaultRoute:
Type: AWS::ApiGatewayV2::Route
Properties:
ApiId: !Ref ModuleWebSocket
RouteKey: $default
AuthorizationType: NONE
Target: !Sub "integrations/${MessageFunctionWebSocketIntegration}"
MessageFunctionWebSocketIntegration:
Type: AWS::ApiGatewayV2::Integration
Properties:
ApiId: !Ref ModuleWebSocket
IntegrationType: MOCK
RequestTemplates:
"200" : '{"statusCode" : 200}'
TemplateSelectionExpression: '200'
PassthroughBehavior: 'WHEN_NO_MATCH'
@joshhoegen
Copy link

Hey @bjorg, I've encountered this too.... any updates?

@bjorg
Copy link
Author

bjorg commented May 5, 2022

@joshhoegen I don't think I ever found a workaround, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment