Reputation: 461
A Redshift cluster is within a VPC that has no direct exposure to internet, but can be reached with ssh tunneling.
I have a lambda function that needs to connect both to internet and this Redshift cluster.
What would be the more natural way to do it?
Should I try to ssh tunneling Redshift public IP from my lambda? How would I achieve this?
Should I put my lambda in another 'internet open' VPC and allow VPC peering? Would this mean security issues?
Thanks a lot.
Upvotes: 0
Views: 630
Reputation: 270134
You basically have two choices:
If the Lambda function is in the same VPC so that it can communicate with the Redshift cluster, and it also requires Internet access, then the configuration would be:
If the Lambda function is outside the VPC, it would need some means of accessing the Redshift cluster. This would be rather messy and would probably be bad for security (eg exposing a port to the Internet). I advise against it.
There is a third method that I would not normally suggest, but might be suitable for you. It involves:
When a Lambda function attaches to a subnet, it creates an ENI. This is the connection between the Lambda function and the VPC. (Actually, it's a connection between the containers that run the Lambda function, and the VPC.)
I noticed that I can attach an Elastic IP address to the ENI and this grants Internet access to the Lambda function. However, ENIs might be created/destroyed by the Lambda service, so this wouldn't necessarily keep working. That is, the ENI might not persist, so the Elastic IP address might not always be attached. Therefore, I advise to use this method with caution.
The "correct" method is to use a NAT Gateway or NAT Instance.
Upvotes: 2