Hey everyone! I have a customer who's working with several EC2 instances that all need static private IPs—they can't use Elastic IPs, and the same private IP should be assigned on each restart or rebuild. The subnet situation is pretty tight as well. The challenge I'm facing is how to manage AMI updates since there's a new AMI released twice a month that needs to be used across these instances. The EC2 instances are deployed via a CloudFormation stack, but when we try to update the AMI, we run into an issue because the Elastic Network Interface (ENI) can't be detached; it's the only ENI present and AWS blocks the removal when it's marked as primary. Has anyone dealt with a similar situation? I'd love any ideas or suggestions!
1 Answer
You might want to check out using a Launch Template for your EC2 instances. With this approach, the association of a preallocated ENI lives within the template rather than the instance itself. There’s an example code snippet you could follow that shows how to achieve this using CloudFormation. You’ll need to create a template for each VM since the mapping of ENI to VM is template-specific.
Thanks, that sounds like a solid solution for this use case.