How to erase/delete entire Elastic beanstalk environment

I ran eb init and set stuff up only to realize that RDS is essentially required if you use a relational database, but you'll only be prompted for it if you pass --database option to the EB create command (definite oversight there IMO).

Anyway, eb terminate only seems to terminate the ec2 instance, not erase the environment information. So, if you want to start fresh with the same environment... you would have to do my-app-<env>2,3,4,5,6? That seems like garbage.

How do you COMPLETELY erase the environment information with the CLI tool?


I believe that eb terminate --all will accomplish what you're looking for.

That being said, I'd recommend against creating an RDS database that's associated with your EB instance. If you do so, then the instance and database are tightly coupled, meaning that if you decide to terminate the instance, the associated RDS database will be destroyed. Among other drawbacks, this will prevent you from implementing blue/green deployments.

In my opinion, it's more flexible to do the following:

  1. Create the EB instance without an RDS instance
  2. Create the RDS instance
  3. Set the appropriate environment variables on the EB instance to associate the two instances together

In Rails at least, the environment variables you'll need to set are as follows:

  • RDS_HOSTNAME=yourinstance.region.rds.amazonaws.com
  • RDS_DB_NAME=ebdb
  • RDS_PASSWORD=password
  • RDS_USERNAME=adminuser
  • RDS_PORT=5432