Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible in aws to have the same IP for EC2 and for a Lambda?

The problem is we are working with UDP based IoT devices, what we want to achieve is that there's a server which receives the incoming udp packets and we will have a lambda connected to an sqs which sends different packets what comes from the sqs. In order to be able to send packets back to the device, it has to come from the same source, meaning the same IP and PORT.

I'm looking for possible solutions, the main idea is to separate packet processing from packet sending into different services.

Diagram

like image 465
alex Avatar asked Sep 15 '25 04:09

alex


1 Answers

I think, here is a solution:

  1. Create NAT Instance that allows IoT Devices to communicate with EC2 instances (need to setup iptables which allows IoT devices IP's to get access to the EC2 instances)
  2. Em-place Lambda functions and EC2 instances in private subnets and allow internet access though NAT Instance

It works only for IP address, each time Lambda will send data to IoT device though NAT instance, packet source port will be ephemeral.

like image 69
Maksim Yersh Avatar answered Sep 17 '25 18:09

Maksim Yersh