AWS Lambda Function Access to EC2 Instances in VPC | DVA-C01 Exam Answer

Ensure AWS Lambda Function Access to EC2 Instances in VPC

Prev Question Next Question

Question

You've developed a set of scripts using AWS Lambda.

These scripts need to access EC2 Instances in a VPC.

Which of the following needs to be done to ensure that the AWS Lambda function can access the resources in the VPC? Choose 2 answers from the options given below.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Answer - A and C.

Options B and D are incorrect since you have to mention the Subnet and Security IDs for the Lambda function to access the resources in the VPC.The AWS Documentation mentions the following.

You can enable AWS Lambda to access resources in a Virtual Private Cloud (VPC)

Your Lambda functions can now access Amazon RDS databases, Amazon Redshift data warehouses, Amazon ElasticCache nodes, and other endpoints that are accessible only from within a particular VPC (e.g., web service running on EC2)

You must provide additional VPC-specific configuration information such as VPC subnet IDs and security group IDs in order to enable your Lambda functions to access resources in an Amazon VPC.

For more information on configuring a lambda function to access resources in a VPC, please refer to the below link-

https://docs.aws.amazon.com/lambda/latest/dg/vpc.html https://aws.amazon.com/about-aws/whats-new/2016/02/access-resources-within-a-vpc-using-aws-lambda/

To ensure that an AWS Lambda function can access resources in a VPC, you need to configure the following:

  1. Subnet IDs - When you create a Lambda function, you need to specify the VPC and subnet IDs that it should run in. The subnet IDs allow the Lambda function to access resources within the VPC.

  2. Security Group IDs - You also need to specify the security group IDs that the Lambda function should use. Security groups act as a virtual firewall that controls inbound and outbound traffic to the resources within the VPC. You can configure the security groups to allow or restrict access based on IP addresses, protocols, and ports.

In summary, to ensure that AWS Lambda functions can access EC2 instances in a VPC, you need to configure the subnet IDs and security group IDs in the Lambda function.