Skip to content

Instantly share code, notes, and snippets.

@dsandor
Created May 4, 2022 13:38
Show Gist options
  • Save dsandor/40890b1d7614b8eb9f902b268169552f to your computer and use it in GitHub Desktop.
Save dsandor/40890b1d7614b8eb9f902b268169552f to your computer and use it in GitHub Desktop.
AWS API Gateway WebSocket route configured for two way request/response.
########## Default Route ($default) Function and APIGW Config ############
DefaultFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: default/
Handler: bootstrap # note, this is the name of the executable output from the Makefile.
Runtime: provided.al2
Architectures: [ arm64 ]
Policies:
- AWSLambdaBasicExecutionRole
Metadata:
BuildMethod: makefile
DefaultRoute:
Type: AWS::ApiGatewayV2::Route
Properties:
ApiId: !Ref Api
RouteKey: "$default"
Target: !Join
- '/'
- - 'integrations'
- !Ref DefaultLambdaIntegration
DefaultFunctionPermission:
Type: AWS::Lambda::Permission
DependsOn:
- Api
- DefaultFunction
Properties:
Action: lambda:InvokeFunction
FunctionName: !Ref DefaultFunction
Principal: apigateway.amazonaws.com
DefaultLambdaIntegration:
Type: AWS::ApiGatewayV2::Integration
Properties:
ApiId: !Ref Api
Description: Default Integration
IntegrationType: AWS_PROXY
IntegrationUri:
Fn::Sub:
arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${DefaultFunction.Arn}/invocations
DefaultRouteResponse:
Type: AWS::ApiGatewayV2::RouteResponse
Properties:
RouteId: !Ref DefaultRoute
ApiId: !Ref Api
RouteResponseKey: "$default"
DefaultIntegrationResponse:
Type: AWS::ApiGatewayV2::IntegrationResponse
Properties:
IntegrationId: !Ref DefaultLambdaIntegration
IntegrationResponseKey: "$default"
ApiId: !Ref Api
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment