In Lambda, if you want to send a message to a WebSocket, you have to supply a HTTPS endpoint for the API Gateway control interface. However there appears to be no way to obtain this URL when the WebSocket is created via CDK,
Use Case
I want to create a WebSocket, and have a Lambda function send messages to connected clients in response to non-WebSocket events (e.g. SQS message arrival). This means I can't extract the WebSocket control address from the Lambda event object as it is not a WebSocket message that has triggered the function. Instead I must pass the WebSocket control URL in via some other method such as an environment variable.
Proposed Solution
There is already a WebSocketApi.apiEndpoint property for the WebSocket itself (minus the stage) so I guess it would work better in WebSocketStage having a property like .controlEndpoint.
So far I have worked around the issue by (in CDK) using a constructed string like this:
`https://${webSocketApi.apiId}.execute-api.${this.region}.amazonaws.com/${webSocketStage.stageName}`
But it would be nicer if this was provided by the library.
Other
This is a 🚀 Feature Request
In Lambda, if you want to send a message to a WebSocket, you have to supply a HTTPS endpoint for the API Gateway control interface. However there appears to be no way to obtain this URL when the WebSocket is created via CDK,
Use Case
I want to create a WebSocket, and have a Lambda function send messages to connected clients in response to non-WebSocket events (e.g. SQS message arrival). This means I can't extract the WebSocket control address from the Lambda
eventobject as it is not a WebSocket message that has triggered the function. Instead I must pass the WebSocket control URL in via some other method such as an environment variable.Proposed Solution
There is already a
WebSocketApi.apiEndpointproperty for the WebSocket itself (minus the stage) so I guess it would work better inWebSocketStagehaving a property like.controlEndpoint.So far I have worked around the issue by (in CDK) using a constructed string like this:
But it would be nicer if this was provided by the library.
Other
This is a 🚀 Feature Request