Reseting an Amazon EC2 instance at reboot

amazon ec2

I'm looking for a way to have some kind of ephemere instances of Amazon EC2.

The idead would be to

  • launch an instance
  • do some work on it
  • reboot the instance (not stopping)
  • reset the hard disk to it's default state.

How can I do the latest step using Amazon mechanisme (or other ideas if this is not possible)?

Edit:

I want to do that because I would like to reset the state of the instance several time by hour without having to pay for a full hour each time. In Amazon you have to pay for a minimum of one hour each time you start an instance. I would like to be able to reset the instance to the initial state because the instance will be used by untrusted users that will have access to a not very secure application. I would like to be able to reset the instance each time a user logout. Only one user at a time will have access to the instance.

Best Answer

I'm not yet able to make comments, but I'm struggling to find the usefulness in what you've asked.

If you're looking to get a blank EC2, you can just terminate the existing one and bring up a new one. That's the AWS way of doing things.

You could create an AMI of the blank EC2 then create a new EC2 based off that blank AMI but that's more or less the same thing as my suggestion in the line above.

You can do all useful things programatically using the AWS APIs, like creating new machines, terminating or rebooting machines etc

If you're able to clarify exactly what you're hoping to achieve (and why you must reboot, not start with a new EC2) maybe we can come up with more tailored/useful solutions.

Edit:

Another approach would be to create an EBS and use that as your disk. Because it's life is independent of the EC2 you can do whatever you want with it. You should be able to restore from an AMI (a backup of a clean image) onto the EBS whenever you like.

Amazon Elastic Block Store – Amazon Elastic Block Store (EBS) offers persistent storage for Amazon EC2 instances. Amazon EBS volumes are network-attached, and persist independently from the life of an instance.