I have recently been recently using Amazon's CloudFormation to launch instances of EC2 Ubuntu machines running MongoDB.

When it comes to deleting the stack it often fails I guess due to not being able to dismount the ebs raid 10 drives Mongo is using.

I would like to something in that template (currently has bash script in user data) or machine to intercept that message, shutdown Mongo and dismount the drives so the delete can happen cleanly rather than having to be performed twice. Is there a simple way to augment CloudFormation to handle stack deletes more cleanly?

I realise there are alternatives (OWS running Chef 9 still / Chef installed on one of our machines in AWS / Juju / Puppet / etc / etc ) but right here and now I just want to get this working cleanly first if at all possible.

1 Answer 1


We have similar problem due to the S3 buckets CF stack created could not be deleted if not empty.

Our solution/hack so far is have a bash script calling the AWS API using aws-cli to iterate though all S3 buckets and delete the contents inside first then call the aws cloudformation delete-stack.

For your problem you can do the same just detach ebs volumes on your Mongo instance before you delete the stack.

  • Thank you, I'll try this out all being well soon. I'll hold out for a couple of days on marking this as the accepted answer just in case someone figures it out just with the templates... though from what you are saying that is impossible :( Jul 26, 2013 at 0:52
  • I agree on this solution.
    – dialt0ne
    Jul 30, 2013 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.