7

I created an Elastic Beanstalk environment with a VPC. Sometimes the environment will lock up on a code version deploy and have to be rebuilt. When this happens I lose my Elastic IP.

I tried disassociating the EIP before the rebuild, but it is still replaced. What can I do to make the EIP permanent!? (Yes, I need an EIP and a CNAME is not sufficient for my purposes)

Tony Gutierrez
  • 753
  • 1
  • 6
  • 16
  • By "on a deploy", I assume you mean you're spinning up a new EC2 instance as a result of a new Beanstalk environment? Or are you simply trying to redeploy to an existing instance? If you can be more specific as to what you're doing, that might help. – Brooks Nov 10 '15 at 06:36
  • I mean a deploy of new code, or a new application version, to an existing instance. I have quite a few different EB environments among many projects, and it is not terribly uncommon for deploys to crash, and the env to require a rebuild. – Tony Gutierrez Nov 10 '15 at 15:50
  • The only thing I can think of is to try and use EB's hooks into autoscaling to detect when the instance has failed and automatically spin up a new instance with the EB deployment and re-map the EIP from the first instance to the second. This should be capable of being automated. – Brooks Nov 10 '15 at 19:23
  • This is a single instance environment. When it locks up nothing responds in the AWS console. Eventually it will get stuck in a red severe state and you can initiate a rebuild. It seems to me like it should just get rebuilt underneath the existing IP, but just like security groups, and everything else, the EIP gets deleted. – Tony Gutierrez Nov 10 '15 at 20:59
  • Tony, I honestly would go to AWS with that. Post it to the forum or something. But have you tried setting some auto scale parameters? – Brooks Nov 10 '15 at 21:24
  • @TonyGutierrez, Did you have any luck with this? I'm having the same issue. – Tanner Semerad Aug 02 '16 at 16:55
  • @TonyGutierrez I have the same issue too. Finding solution for it... – user1533481 Dec 26 '16 at 04:02

2 Answers2

0

Replace Root Volume

You can use the "Replace root volume" feature (available since Apr/2021).

From the CLI:

aws ec2 create-replace-root-volume-task --instance-id INSTANCEID

From the Console:

EC2 > Right click on instance > Monitor and troubleshoot > Replace root volume

Leave the snapshot ID blank.

Shai Coleman
  • 868
  • 15
  • 17
0

If you spin up a elastic beanstalk environment in an VPC's subnet with an NAT gateway which already exists. I believe if Elastic beanstalk did not configure your EIP it should not automatically release it. Just saying that I have never experienced this issue you are raising here; My deployments never result in random crashes. You should check out why this happens and resolve that aswell.

I think this is maybe the difference between you and my setup: I configured elastic beanstalk in an already created VPC. I used this guide to create my VPC and subnets; maybe this is helpful for you too:

https://spinupwp.com/scaling-laravel-using-aws-elastic-beanstalk-part-2-setting-up-vpc-rds-elasticache/

What you can also do is a Green/Blue deployment on major software releases. You create a new EB environment you can copy the configuration of your current environment or with help of .ebextensions and hooks predeploy/postdeploy configure your environment for you. This will help you test/wait until the new deployment is stable and switch the DNS of your EB environments: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.CNAMESwap.html

Max Visser
  • 577
  • 4
  • 10