Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the downside of NOT running AWS Lambda functions in a VPC?

I am running AWS Lambda functions in a VPC.

And during the course of the project I have hit problems because:

  • no access to my database - had to solve this somehow
  • no access to AWS SES - had to find workaround
  • no access to AWS SQS -removed all queuing functionality from Lambda functions
  • no access to external Internet - still don't know how to implement ReCapthca without Internet access
  • no access to AWS Cognito - cannot get information about logged in users

I COULD implement a NAT gateway in the VPC but what is the point of serverless if I have to run a NAT server instance? That's not serverless.

So finally AWS has worn me down and I have decided to give up on running my AWS Lambda functions in a VPC - without endpoints for Internet proxying and the various AWS services its just too hard.

SO my question is - what is the downside/disadvantage of running my AWS Lambda functions with no VPC?

like image 285
Duke Dougal Avatar asked Aug 09 '17 02:08

Duke Dougal


People also ask

Does my Lambda need to be in a VPC?

You don't need VPCs to secure Lambda This is the same mechanism that protects most other AWS services. If services such as SNS and DynamoDB are considered secure, even though they don't run inside a VPC, then why shouldn't Lambda functions be considered secure when they are protected by the same IAM service?

Why use AWS Lambda in a custom VPC?

AWS Lambda executes your code only when needed and scales automatically from a few requests per day to thousands per second. With AWS Lambda, you pay only for the requests served and the compute time required to run your code.

Can you invoke a Lambda in a VPC?

So a public (non-VPC, has Internet access) Lambda function can call the Invoke API to trigger the private Lambda function, but the private VPC (no Internet access) Lambda function cannot access the Invoke API to trigger any Lambda function.


2 Answers

If you need access to resources within a VPC, then run your AWS Lambda function within a VPC. If you do not require this access, then do not run it within a VPC.

If you require Internet access, then you should connect your Lambda functions to a Private Subnet and use a NAT Gateway, which is a fully-managed NAT so you can remain serverless. It will solve the problems you listed.

like image 50
John Rotenstein Avatar answered Oct 01 '22 02:10

John Rotenstein


AWS has provided a reference document for Lambda deployments: Serverless Application Lens, AWS Well-Architected Framework. In it they provide the following decision tree:

Decision tree for deploying a Lambda function in a VPC

The only major downside noted is that a Lambda outside of a VPC cannot directly access private resources within a VPC.

like image 21
Ramón J Romero y Vigil Avatar answered Oct 01 '22 03:10

Ramón J Romero y Vigil