Restrict Lambda URL to specific VPC (for EC2 Instance)

Viewed 28

I have a few Lambda that are executed from a Jenkins installed on a EC2 instance. I could successfully run a curl command from Jenkins to request any of a my Lambda using the URL.

I'd like to secure this architecture with a VPC. My EC2 instance already under the VPC vpc-001f4912569686a89 so I've put my Lambda under the same one.

I have also created a security group (sg-0de1a07dd602450f7) for my Lambda to allow only traffic from my EC2 instance. See the following (sg-0f62df4def386f83a) is my EC2 instance's security group) : enter image description here

And here is my Lambda VPC configuration: enter image description here

From what I understand, this should be enough to get my EC2 to communicate with my Lambda but my curl isn't returning me anything (probably a timeout).

EDIT

Here is my VPC route table : enter image description here

1 Answers

Your security group setup seems correct.

Please address the following items:

  • Could you elaborate on the subnet that your EC2 Instance is running in?
  • Your Lambda function's container(s) can spawn in either of the two subnets
    • subnet-053af8185c4f6bbc7
    • subnet-0ac074c5b63e6db9b
  • Please check the VPC's route table and ensure traffic can flow between the potential subnets
  • Please check the Lambda function's subnets' ACLs to ensure they're not blocking traffic coming from the Jenkins instance
Related