Cleaning Up

If you no longer need your AMI you should deregister it from Amazon EC2.

For this step you'll need your AWS Access Key ID (<aws-access-key-id>) and AWS Secret Access Key (<aws-secret-access-key>). The steps to find these were covered in the section called “Signing up for Amazon S3.

You can deregister your AMI with the following command:

PROMPT>  ec2-deregister ami-5bae4b32 
IMAGE ami-5bae4b32 

You may delete your deregistered AMIs from Amazon S3. If you don't then you will continue to be charged for the space you're using.

You will need to have the ec2-ami-tools installed to delete your image. You can get these from resource center or they are installed on the instance from which you you created the image.

You can delete your AMI with the following command:

PROMPT> ec2-delete-bundle -b <your-s3-bucket> -p image -a <aws-access-key-id> -s <aws-secret-access-key> 
Deleting AMI bundle parts from https://s3.amazonaws.com/<your-s3-bucket>...
Deleted image.part.00.
Deleted image.part.01.
Deleted image.part.02.
Deleted image.part.03.
...
Deleted image.part.23.
Deleted image.part.24.
Delete Bundle complete. 

As soon as your instance starts to run, you will be billed for the resources being consumed. Once you have decided that you no longer require its services, you can terminate an instance using the instance identifier you received in the section called “Running an Instance”.

PROMPT>  ec2-terminate-instances i-10a64379 
INSTANCE i-10a64379 running shutting-down 

It will take a few minutes for the instance to terminate because we need to clean-up your data. You can check on the status of the instance as in the section called “Running an Instance”.

You can also terminate your instances by logging onto the instances with your ssh tool and running the "shutdown -h" command. Don't forget the "-h", otherwise you will put your instance into single user mode. You will find this quite useless.

#  /sbin/shutdown -h now