Elastic IP Assignment for Auto-Scaling EC2 in VPC-AWS

My goal is to automatically assign elastic IP to an EC2 instance with automatic scaling.

I did the following: - A configured instance of EC2 with a launch script to assign an IP address - A configured startup configuration and an autoscale group for each specification.

The problem is that when I deploy an automatic launch configuration, I lose the ability to let it automatically assign a shared address (first) before it picks up an elastic IP assignment.

When I deploy AMI manually, provided that I verify that "assign public IP address", the instance will deploy, temporarily assign the address xxxx.amazon.xxxx, and then flip to my elastic IP assignment.

but..

when deploying through the command line utilities, the autoscale (as-create-launch-config + as-create-auto-scaling-group) IP will not work. I feel this can be fixed if there is an option when configuring the launch configuration to temporarily grab the public IP address, to contact the amazon API to pull out the elastic destination.

I really appreciate your help!

+4
source share
1 answer

You can use cloud-init to run the command on a local autoscaled server that connects to EIP. The following is an example of a local command running on the server on first boot: http://cloudinit.readthedocs.org/en/latest/topics/examples.html#run-commands-on-first-boot

In this local command, you can use the amazon built into the tools to link the address: http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-AssociateAddress.html

In the startup configuration, add this cloud-init syntax to the user-data attribute as base64 encoded, and all future autoscaled instances will do what it will do with cloud init.

I usually encode base64 by doing:

base64 <filename> 
+1
source

Source: https://habr.com/ru/post/1498477/


All Articles