how to allocate elastic IP address to auto scaling group?

0

I have allocated an elastic IP address to the auto-scaling group. after traffic increases, it creates another instance with a new IP address. the newly generated IP address is not assigned automatically to the elastic IP address.

Arshad
asked 3 months ago56 views
2 Answers
1

You could use a Proxy or NAT-Gateway in front of the EC2 fleet that way regardless of the ASG activity externally NAT-Gateway EIP will be seen as the source IP.

profile picture
EXPERT
answered 3 months ago
0

An EIP (or any public IP) can only be assigned to a single instance/ENI, you can't assign it to multiple instances as you scale. AutoScaling only supports a static EIP when the group has a max of 1 instance (in which case that EIP/ENI can be reused on replacement instance, but the group can't scale above 1 instance). What is your goal here?

A static inbound IP?

  • Use a Network Load Balancer (NLB) and attach its target group to the ASG. NLB IPs are static and never change with 1 EIP per AZ

Static outbound IP?

  • Use a NAT Gateway

Both?

  • You'll need to create a pool of unused EIPs, and then create a userdata script in the Launch Template for your AutoScaling Group. The script will need to search for available EIPs and attach one to the instance

Note that all 3 of the above options have varying levels of cost associated with them.

answered 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions