简体   繁体   中英

Elastic IP and Autoscaling in AWS

I have deployed a webservice application in Amazon EC2 and has associated an Elastic IP address with the same. Our mobile interact with this webservice using elastic IP. Now I want to implemented auto scaling on the EC2.

But what I am not sure is how does my single elastic ip be associated with multiple EC2 instances as it scales up? Is this possible. Please guide.

An elastic IP address is only ever associated with a single EC2 instance.

If you want to start auto-scaling your application, then you need to put a load balancer in front of your EC2 instances. That can be AWS Elastic Load Balancer, or some other.

Users would connect to the Load Balancer, and the Load Balancer would forward requests to the underlying EC2 instances.

Assuming you use an Elastic Load Balancer, you'll need to drop the Elastic IP address since ELB cannot use them. Instead, you'll create a CNAME (or Alias if your DNS is using Route 53) to the ELB.

No that's not possible. You probably need to be using an Elastic Load Balancer.

With EC2 & Auto scaling, You need using user data in EC2 to Auto Attach Elastic IP to EC2 Instance For Auto scaling

#!/bin/bash
aws configure set aws_access_key_id "XYZ..."
aws configure set aws_secret_access_key "ABC..."
aws configure set region "ap-..."
aws ec2 associate-address --instance-id "$(curl -X GET "http://169.254.169.254/latest/meta-data/instance-id")" --public-ip your_elastic_IP

Note: you should create new user & IAM have only permission associate-address to create/get aws key

Hope it be help you :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM