Search code examples
amazon-web-servicesamazon-ec2aws-lambdawebsocket

Websocket/TCP connection to an EC2 instance from AWS Lambda?


Is it possible to initiate a temporary (10 mins) Websocket/TCP connection to a server on an EC2 instance from AWS Lambda?


Solution

  • That's possible under a few conditions:

    • your Lambda Timeout is greater than 10 minutes
    • your Lambda Function is deployed into a VPC (only if the EC2 instance isn't accessible from the Internet)
    • The security groups on the instance and the Lambda function allow connectivity
    • The connection is initiated from your Lambda function (as Lambda execution contexts can't accept inbound connections)