1

"Spot Requests" has a really useful option called "Maintain target capacity". With this, I am sure that the server will be always there. But there is no way to automatically assign an IP address to the newly created server after the last one was terminated due to higher bidding.

I have to assign the IP address manually even if the server is created automatically.

How to automate this step?


As per one of the blog post, these 2 lines should be saved in user data section of an instance while it is being initiated.

pip install aws-ec2-assign-elastic-ip

/usr/local/bin/aws-ec2-assign-elastic-ip --access-key ACCESS_KEY --secret-key SECRET_KEY --valid-ips IP

Can I use it for persistent spot request?

shantanuo
  • 31,689
  • 78
  • 245
  • 403
  • In other words how do I use boto to find the instance ID (i-000702830b53f5d32) currently associated with Spot Request Id: sfr-51319954-4575-4e22-815b-4236c96244de and then assign IP address to that instance? – shantanuo Nov 26 '18 at 08:06
  • 1
    I would adapt the proposal in [this thread](https://serverfault.com/questions/559282/automatically-assign-elastic-ip-to-ec2-spot-instance-with-user-data-script). Old and partially deprecated---the important part is to use "user data" to run a script on startup of the spot instance. [Example here](https://serverfault.com/questions/592423/how-do-i-launch-an-amazon-ec2-spot-instance-with-userdata/625620). By the way, your question may be better on ServerFault. – Eric Platon Dec 02 '18 at 02:20

0 Answers0