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
I find it's either you open your Redshift security group public to all sources, or none. Because a Lambda function isn't running on a fixed address or even a fixed range of IP addresses, which is completely transparent to users (AKA server-less).
I just saw Amazon announced the new Lambda feature to support VPC yesterday. I guess if we can run a Redshift cluster in a VPC, this could solve the problem.