Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect elasticache and dynamoDb from aws-lambda without using NAT Gateway

I need to connect dynamoDb and elasticache from aws-lambda (otherthan using NAT Gateway).

ElastiCache provides essential caching methods along with help in making the Lambda state-ful. The concern is that for Lambda to work nice with DynamoDB it should be set to NoVPC.

If we have to use ElastiCache, Lambda and both have to be in the same VPC.TO use Both ElastiCache and DynamoDB together is quite a challenge specially with Lambda. Given the VPC challenges.Do you have any suggestions to make this easier?

like image 650
Abdul Manaf Avatar asked Jun 23 '16 09:06

Abdul Manaf


People also ask

Do you need a NAT gateway for Lambda?

Internet access from a private subnet requires network address translation (NAT). To give internet access to an Amazon VPC-connected Lambda function, route its outbound traffic to a NAT gateway or NAT instance in a public subnet. For more information, see Internet gateways in the Amazon VPC User Guide.

Can Lambda connect to ElastiCache?

Create a Lambda function to access the ElastiCache cluster. When you create the Lambda function, you provide subnet IDs in your Amazon VPC and a VPC security group to allow the Lambda function to access resources in your VPC.

Can we use ElastiCache with DynamoDB?

Why use ElastiCache? Applications often need a durable, powerful database for their primary data storage. This could mean a relational database, such as Amazon Aurora, or it could mean a NoSQL database, such as DynamoDB or Amazon DocumentDB (with MongoDB compatibility).


1 Answers

A Lambda function would have to have VPC access to connect to ElastiCache, and it would have to have access to resources outside the VPC to access DynamoDB so it would require a NAT gateway. There is no way to provide access to both of those services to a single Lambda function without enabling VPC access and setting up a NAT gateway.

If you just need a Redis server and aren't required specifically to use ElasiCache, then you could use a RedisLabs instance which wouldn't require you to enable VPC access on your Lambda function.

like image 138
Mark B Avatar answered Oct 27 '22 04:10

Mark B