36

I get a message when I am trying to deploy my php app on EC2 using Elastic Beanstalk.

Environment named *** is in an invalid state for this operation. Must be Ready.

I am unable to deploy. The server status is running, no warnings.

My experience is very limited at this point. How can I resolve this?

Tim
  • 30,383
  • 6
  • 47
  • 77
Dr Casper Black
  • 605
  • 1
  • 7
  • 12
  • 1
    Did you solve the problem? I had the same problem. My environment is green and healthy but I can´t apply any change on it. I waited days and nothing changed. – Rafael Leonhardt Mar 31 '16 at 20:01
  • This issue will also occur if you try to run two deploys against the same environment simultaneously. – skeggse Jul 01 '16 at 19:03

13 Answers13

14

Usually, there's no way to recover from an invalid state for a given environment.

In such cases, you need to go to the current environment page, click on the Actions button, select Clone Environment, and then wait for the clone environment to be created. Once it's ready, you can go to the application page, click on the Actions button and then select SWAP URLs.

Finally, you can go to the inconsistent environment page and choose to terminate it.

anderson
  • 191
  • 3
  • 7
  • Presumably if you want to retain the environment name, you'll have to do this twice (first to switch to a temporary environment name). Alternatively, if you can afford the downtime, there's an option to 'Rebuild Environment', which seems to fix this issue. – Joe Freeman Apr 30 '16 at 14:33
  • "Rebuild Environment" doesnt help when AWS provisions you one with too small of a DB instance for the RDS instance type chosen :( – Todd Dec 14 '16 at 21:40
  • I think this is a bit drastic, considering I had a similar issue and simply restarted the server to get it working again – Jad S Jan 15 '18 at 12:50
  • 12
    AWS won't let me clone an environment if it's not "ready" – posit labs Feb 13 '19 at 22:33
  • @positlabs, I had to rebuild because cloning and restarting threw the same error you mentioned. – adam-m-hanna Aug 27 '19 at 18:29
  • 1
    If you can't clone the environment on the EB dashboard (per @positlabs), try [cloning via the CLI](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-clone.html). – Derek Soike Sep 19 '19 at 21:18
9

I solved this problem by going to Elastic Beanstack, my app was GRAY status/health, from the app overview I accessed the Actions button and Aborted the current operation.

Then I got the health status GREEN, and managed to deploy.

Dr Casper Black
  • 605
  • 1
  • 7
  • 12
  • This worked for me too, even though my application doesn't respond to the health check URL I configured (`/health`). Note that you may need to be patient! Since triggering the abort, it took 17 minutes before EB was happy enough for me to perform my next action. – stwr667 Sep 07 '21 at 13:21
4

This happened to me. If this is a newly created app you should wait a few moments for the environment to come online, then try again. It should work.

4

Go to Actions -> Rebuild Environment. That solved the problem for me. Hope it helps! AWS Elasticbeanstalk Menu: Actions -> Rebuild

1

last time it happened i was able to clone using cli but now I'm having worst issue, I created new ami then I did update the environment then I aborted the update, but the old AMI is already deleted, now I'm stuck and cloning the environment doesn't help because the old AMI is no longer exists

I also tried to update the AMI using awscli and still getting the same message!

this question is now 4 years old and still no solution provided by AWS..!

1

It happened when I aborted when it was in

INFO: Environment update is starting.

state (right after "Uploading").

It returned back to Ready after a few minutes, I just had to wait.

denis.peplin
  • 111
  • 3
1

Rebuilding environment worked for me, but it does incur a downtime if the application is already running. As mentioned Blue Green deployment is the correct way out of it.

1

In my case, I couldn't execute any action on the Elastic Beanstalk. I had to rebuild the entire Elastic Beanstalk Application with a new Load Balancer.

kimy82
  • 111
  • 3
  • Mine was caused by an invalid cert in the load balancer. The mechanism to change the bad cert requires the cert to be valid. Ope – jws Jun 11 '20 at 16:16
0

If you use autoscaling, set your min and max instances to 0. Wait for the environment to update, then revert back to your original values.

digout
  • 101
  • 2
0

Só consegui resolver clonando o ambiente e removendo o anterior. Não aceitava nem recriar, clonei e depois exclui o antigo.

Agradeço o conselho de vocês ajudou muito.

0

Also had this problem recently while testing permissions. I set up an IAM policy to test tagging environments that were not prod. The tag creation failed as the policy was lacking a few related permissions (ec2, autoscaling) but this failed attempt to add a tag completely destroyed the environment leaving no choice but to rebuild it. Way to go AWS!

J99
  • 101
0

in my case that happened because i start creating an RDS Database without waiting the creation of environment. to correct this you need to rebuild environment

0

In my case I had first deleted the RDS instance, then tried deleting the Environment so Elastic Bean was looking for my RDS instance which it couldn't find.

So I went to RDS and restored the database associated with my Elastic Bean environment.

It worked!

ahcyT
  • 101
  • 1