'How to assign a static Private IP's to AWS EC2 instances in an AutoScalingGroup for High Availability via cloudformation?
I have a cloud formation pipeline that builds an AutoScalingGroup in AWS and deploys a couple of EC2 instances in High Availability to run an application service on. The problem is that when I push an update through the pipeline the existing nodes are terminated and swapped out for the new updates in a blue/green deployment style creating new EC2 instances with new Instance ID's and new IP's
How can I ensure that when node 1 is terminated and replaced with the updated node 1 that the updated node will have the same private IPv4 as the one before it?
I have tried with AWS EIP and ENI and I cant find a way that works since each node has a different subnet ID and Availability Zone.
These are two options I have found so far:
- https://binx.io/blog/2019/09/10/how-to-dynamically-bind-static-private-ip-addresses-to-an-auto-scaling-group/
- aws cloudformation "NetworkInterfaces" in Autoscaling launchconfig group
Option 1 wont work for me as it mentions the autoscaling group should be bound to a single AZ which is not my use case.
I dont understand what option 2 is doing or how to implement it and so I have not been able to try it.
The one idea I had was to create an ENI within the cloudformation script for each node that will be spun up and attach it based on Instance ID of the node spun up. But I do not know if that will work or how to achieve it since I will need to reference the SubnetID and InstanceID of each node as its created to then attach the ENI correctly
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
