I created an AWS Lambda function that:
Locally, using Node, I can successfully connect to
If you are using serverless-framework v1.5.0, you should add:
iamRoleStatements:
- Effect: Allow
Action:
- ec2:CreateNetworkInterface
Resource: '*'
- Effect: Allow
Action:
- ec2:DeleteNetworkInterface
- ec2:DescribeNetworkInterfaces
Resource: 'arn:aws:ec2:${self:provider.region}:*:network-interface/*'
Also should add all securityGroupIds to Inbounds Rules, like below:
More info: https://serverless.com/framework/docs/providers/aws/guide/functions/#vpc-configuration