I am building a workflow that goes from AWS MediaLive to a set of 2x EC2 instances residing on 2 different availability zones. The EC2 instances are spun from and autoscaling group that is set to always keep 2 instances running (1 per AZ).
Per sé this would not be a problem except that I need the two MediaLive pipelines to always point to a specific instance and not the other. As you may know a private IP is changed every time an instance is spawned so I have a hard time to point MediaLive in a way that does not require restarting the stream every time instances change.
So question is: how can I reuse the same private IP and assign it to the new instance spawning in the same availability zone?
Consider that so far I have been trying several combinations of Launch Templates (that always fail to launch) and tried to create (and assign) a /31 subnet to each AZ only to find out a max of /28 can be created.
Thanks a lot, Federico
Ok, so after serveral failed attempts from the AWS console I decided to try something different and worked my way using the User Data script.
As the max number of EC2 instances is known in advance, it is trivial to create enough network interfaces and then manually attach them until all are assigned.