Cleaning Up

In addition to creating resources for deploying BOSH, bbl has two subcommands for assisting you in cleaning up an environment after you are done with it: bbl down and bbl cleanup-leftovers.

bbl down

If you have the state file for a working environment, then bbl will destroy everything it has created.

As a safety precaution, bbl will not delete the environment if there are running VMs deployed by the BOSH director.

bbl down

bbl cleanup-leftovers

Sometimes, bbl down isn't enough to do the job. Perhaps you are in one of these situations:

  • bbl down failed during deletion and lost information.
  • The bbl-state-dir is on a computer that you no longer have access to.
  • You created resources outside of bbl that you want to nuke.
  • You are running bbl's acceptance tests and they failed, orphaning IaaS resources.

To assist with these situations, we have incorporated the cli utility leftovers as a subcommand in bbl.

You can think of bbl cleanup-leftovers as kind of like bbl down --force, but without the need for a bbl-state-dir.

The filter is very important!

If --filter is omitted, bbl will begin to delete ALL of your IaaS account's resources.

For example, if you had a bbl environment with a name autogenerated by bbl you could supply part of the name to delete it:

export BBL_IAAS=aws
export BBL_AWS_SECRET_ACCESS_KEY=foo
export BBL_AWS_ACCESS_KEY_ID=bar

bbl cleanup-leftovers --filter malawi

This will begin to delete each resource with a name or tag matching "malawi", confirming each one before deletion.

Use caution with your filters, because you may have more than one environment with the same "Lake Name". To delete all resources with that name without needing to confirming each one individually use --no-confim:

bbl cleanup-leftovers --filter malawi --no-confirm

bbl cleanup-leftovers will do the best it can to delete in an order such that all resources can be deleted without dependency errors.

However, running cleanup-leftovers repeatedly may be enough to resolve dependency errors.