AWS Lambda to access EC2 with appropriate security group settings

I have my MongoDB living on AWS EC2, and my Lambda function (python code) is trying to access it through the IP address 23.23.23.23:27017. At our company, we restrict our EC2 instances to our company IP address by configuring AWS security groups on an EC2 instance. The problem is that you are not sharing port 27017 with all the traffic in my EC2 instance security groups. My lambda will not be able to access it, because we do not know the IP address on which Lambda is running.

Is there a better way to access the ports of EC2 instances from AWS, such as Lambda, without breaking security rules?

+4
source share
4 answers

Not sure why everyone says VPC endpoints will allow this. VPC endpoints allow communication that occurs in your VPC to access AWS services outside of the VPC. The question asked is about lambda functions that exist outside of VPC, access to EC2 instances that exist in VPC.

Support for running Lambda features in VPC will be available soon, like this announcement . This will solve the problem that this question asks.

+4
source

AWS , IP- AWS. AWS , IP- IP- AWS

, :

  • , , iptables Windows IP- IP- AWS. IP- , . , .

  • API, , Simple Queuing Service, .

  • IP- , reset . , . .

+3

- VPC , EC2, Mongo DB, MongoDB -.

- - , CIDR, EC2.

IP-, CIDR.

0

Please follow this link to assign a Lambda function with a VPC subnet and a security group. And most importantly, make sure you use the PRIVATE IP of the EC2 instance when starting from Lambda.

https://docs.aws.amazon.com/lambda/latest/dg/vpc.html

0
source

Source: https://habr.com/ru/post/1624461/


All Articles