How critical is it that a Lambda Function be deployed in a vpc

0

I'm deploying a lambda function using AWS Cloudformation template and cfn_nag requires this to be deployed in a VPC "Lambda functions should be deployed inside a VPC". If this is critical how would I go about ensuring that the VPC will allow the lambda function to reach the internet?

3개 답변
1

There are 3 reasons to attach a function to a VPC:

  1. You need to access private resources from the Lambda functions.
  2. You need outgoing traffic from the Lambda function to show as coming from a specific IP (in order to add it to an allow list). You do it by attaching the function to the VPC and configuring a NAT Gateway with an Elastic IP address.
  3. You need to have some control over the outgoing traffic from the function. You do it by deploying some outbound proxy that can inspect the traffic and routing the function to that proxy.

Besides those reasons, there is no enhanced security for your function, and there is no reason to attach it to the VPC.

profile pictureAWS
전문가
Uri
답변함 10달 전
profile picture
전문가
검토됨 한 달 전
0
수락된 답변

Looking at enterprise level, it is important to create your resources like lambda function within VPC (not necessarily it helps for endpoints but also from enterprise security point of view). Also following the AWS best practices, the name of lambda function should be limited to certain prefix along with assumed role permissions to pass lambda execution role. In terms of network settings, having mandatory to select VPC with atleast 2 subnets and a security group should be enforced while giving different teams the permissions to create lambda functions.

From security point of view (depends upon at what elevel you want to work), it is not recommended to have public internet connected to your resources directly and have an architecture designed within your private VPC in your enterprise.

If working at workload accounts for multi-account strategy, SCP can be enforced at management account level for all member accounts, so same practice is followed at organization level.

profile picture
답변함 10달 전
profile picture
전문가
검토됨 한 달 전
  • Attaching a function to a VPC does not help with its security posture. Even when you attach the function to a VPC, the invocation is still done via Lambda's public API. You need to have the appropriate permissions to invoke the function.

  • Yes sure, I agree with the statement as VPC alone is not complete solution for security, but it also depends upon how AWS is accessed in an organization within own VPN as well as how IAM permissions are granted for different stages of work like dev to prod with recommended automation pipelines in production to invoke lambda function or event trigers as well but I agree with your point above.

0

I believe lambda only needs to be connected to your VPC if you wish for it to consume resources (VPC endpoints etc) or access databases such as private RDS.

Connecting lambda on your VPC gives you the extra control and monitoring of network traffic.

If lambda is connected to your VPC, ensure it’s connected to a subnet which has a route to a NAT gateway.

NAT gateway then routes to an Internet gateway.

profile picture
전문가
답변함 10달 전
profile picture
전문가
검토됨 10달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠