Describe the feature
Currently, Amazon.CDK.AWS.Apigatewayv2.Alpha lacks support for AWS option as the IntegrationType for WebSocket Apigateway.
The quote from the documentation:
AWS: for integrating the route or method request with an AWS service action, including the Lambda function-invoking action. With the Lambda function-invoking action, this is referred to as the Lambda custom integration. With any other AWS service action, this is known as AWS integration. Supported only for WebSocket APIs.
The important part is:
With any other AWS service action, this is known as AWS integration. Supported only for WebSocket APIs.
That is, you can create a WebSocket Apigateway that calls directly other AWS services without a Lambda function middleware.
Use Case
Ability to create a CDK for WebSocket Apigateway where I can define a direct integration to another AWS service.
For example, WebSocket route integration that triggers a AWS Step Function directly.
This use case is supported using CloudFormation and SAM as follows:
ApiAuthenticateRouteIntegration:
Type: AWS::ApiGatewayV2::Integration
Properties:
ApiId: !Ref BrokerRobotSocketApi
IntegrationType: AWS
IntegrationMethod: POST
IntegrationUri: !Sub "arn:aws:apigateway:${AWS::Region}:states:action/StartExecution"
CredentialsArn: !Sub "${ApiAuthenticateIntegrationStateMachineExecutionRole.Arn}"
TemplateSelectionExpression: \$default
RequestTemplates: # see: https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-mapping-template-reference.html
"$default" :
Fn::Sub: >
#set($statesInput=$util.escapeJavaScript($input.json('$.data')).replaceAll("\\'","'"))
{
"input": "{\"data\":$statesInput, \"metadata\": {\"requestId\":\"$context.requestId\",\"connectionId\":\"$context.connectionId\",\"domainName\":\"$context.domainName\",\"stage\":\"$context.stage\"}}",
"stateMachineArn": "${BrokerAuthenticatorStateMachine}"
}
Proposed Solution
From dotnet world, the solution requires the creation of another class that inherits from WebSocketRouteIntegration to expose the specific props needed for IntegrationType as AWS.
I propose a class named WebSocketAwsIntegration, following the convention for the other integrations types already implemented: WebSocketMockIntegration, WebSocketLambdaIntegration.
Alternatively, we could be even more specific and create classes such as WebSocketStepFunctionIntegration, however, this would require considerably more work because we would need to create several classes for every AWS service that is supported with this construct.
In any case, this would require the following changes - looking briefly at the code:
Adding the following missing properties: IntegrationMethod, RequestTemplates, CredentialsArn, TemplateSelectionExpression, and probably others depending on the AWS service you want to integrate.
Adding the following option to the enum: AWS.
Other Information
No response
Acknowledgements
CDK version used
v2
Environment details (OS name and version, etc.)
Windows 11
Describe the feature
Currently,
Amazon.CDK.AWS.Apigatewayv2.Alphalacks support forAWSoption as the IntegrationType for WebSocket Apigateway.The quote from the documentation:
The important part is:
That is, you can create a WebSocket Apigateway that calls directly other AWS services without a Lambda function middleware.
Use Case
Ability to create a CDK for WebSocket Apigateway where I can define a direct integration to another AWS service.
For example, WebSocket route integration that triggers a AWS Step Function directly.
This use case is supported using CloudFormation and SAM as follows:
Proposed Solution
From dotnet world, the solution requires the creation of another class that inherits from
WebSocketRouteIntegrationto expose the specific props needed for IntegrationType as AWS.I propose a class named
WebSocketAwsIntegration, following the convention for the other integrations types already implemented: WebSocketMockIntegration, WebSocketLambdaIntegration.Alternatively, we could be even more specific and create classes such as
WebSocketStepFunctionIntegration, however, this would require considerably more work because we would need to create several classes for every AWS service that is supported with this construct.In any case, this would require the following changes - looking briefly at the code:
WebSocketRouteIntegrationConfigAdding the following missing properties: IntegrationMethod, RequestTemplates, CredentialsArn, TemplateSelectionExpression, and probably others depending on the AWS service you want to integrate.
WebSocketIntegrationTypeAdding the following option to the enum:
AWS.Other Information
No response
Acknowledgements
CDK version used
v2
Environment details (OS name and version, etc.)
Windows 11