If I stop an EC2 instance, rather than terminate, will this image be saved in my account and be available to be used at a later stage? ..as I noticed terminated instances eventually dissappear, would a stopped instance be available to boot up and start when ever?
Also regarding charging, I assume the cost for having a stopped instance would be charged per GB similar to a custom AMI?
Also another possibly simple question, if I shutdown a machine over SSH or via a script, does this initiate a termination or just a stop an instance (I assume it terminates the instance).
Thanks
If you terminate the EBS backed instance, it will remove it from the list of running instance, including it's allocated EBS volume. Unless you set the instance attribute not to delete the volume.
If you only stop, it will changed to stopped status and you can start it again later.
If you shutdown a machine, it default's to stop.
A good read to protect your instance see: http://alestic.com/2010/01/ec2-instance-locking
If you stop an instance based on EBS, then the instance will terminate automatically but you'll be charged for EBS storage until you delete the EBS.
Related
I had three EC2 instances of a total of 30GiB and ran out of space on the instance running Cloud9, so I terminated one to reclaim storage, however even after 10 hours, the storage from the terminated instance has not been added to either of the other two instances.
Shouldn't the storage reclaimed from the terminated instance be automatically added to either of the active instance?
The terminated is confirmed terminated, does not display on the EC2 instances' dashboard.
I explored the AWS Docs and realized:
The storage isn't added (aka attached) automatically!
If you have terminated your EC2 instance, like I had, then you need to create a new EC2 instance, then detach the storage from this newly created instance and attach it to your existing instance and then mount this to an existing mount point or to a new one.
Deep appreciation for the thorough, detailed and abundant official documentation of AWS.
I have created one AWS EC2 ubuntu instance to host my backend.
I mark it as Terminated.
Can I delete the Terminated Instance by AWS EC2?
Or the instance is stay in my dashboard.
Thank you in advanced.
Quick Answer: After terminattion, it will be deleted automatically after some time.
Terminating your instance is essentially deleting it, it will take
some time to get reflected on your dashboard (meaning it won't appear
on your instance list table)
There is no use of terminated instances.
Once you terminated your instances, it means you have completely lost
that particular instance.
But during the time of creation of your instance if have you had enabled the option called Protect against accidental termination. Then you will not be able to terminate without disabling this option.
But in your instance table if the Instance State column has the value terminated it means your instance is deleted and you can no longer use it.
Note By default, Amazon EC2 deletes the Amazon EBS root device volume at instance termination. Additional volumes that were attached when the instance launched and any volumes that were attached after instance launch persist. For more information, see Preserving Amazon EBS Volumes on Instance Termination in the Amazon EC2 User Guide for Linux Instances.
You really don't need to delete the instance.
From Documentation
After you terminate an instance, it remains visible in the console for a short while, and then the entry is automatically deleted. You cannot delete the terminated instance entry yourself.
How to replace a Amazon EC2 instance with a new instance without removing tomcat7, mysql and other setting done on the instance?
Simple:
Stop the instance.
Detach the volume(s) - if you just have one volume (the boot volume) detach that.
Take a snapshot of the volume(s) for safekeeping (not strictly necessary in this case, but no-one ever got fired for taking backups of critical systems).
Terminate the instance.
Spin-up a new instance of the desired type (must be the same platform, i.e. x86 or x64, as the original).
Wait until it's running, then stop it.
Detach its' volume and delete it.
Attach your original volumes to it (the boot volume must be /dev/sda1).
Restart the new instance and re-assign Elastic IP if appropriate.
What is the different between starting an AWS Image and Instances?
Example:
I do notice when I am running AWS image using boto, I can only stop the Image while running AWS instance using boto, I can only terminate.
Think of an EC2 instance as a single running server with CPU, memory, hard disk, networking, etc. Any changes you make to that instance affect only that instance.
Think of an AMI (Amazon Machine Image) as an exact copy of the root file system that gets copied to the hard disk when you start a new instance. The AMI is a hard disk sitting on a shelf. You make an exact copy of the hard disk on the shelf, install the new hard disk in a server, and turn the server on. You can do this for as many servers as you'd like to start without affecting the master copy.
The AMI defines the initial state of each instance. Each instance changes as it runs, but you can never change the original AMI once it has been created (other than to delete it).
There are more details that refine this conceptual model, but that's the basics.
Specific to the wording in your question:
Sometimes we say we're "starting an AMI" sometimes we say we're "starting an instance". We mean the same thing. We're really starting an instance using an AMI as the template.
We never say we're "stopping/terminating an image" or "stopping an ami" as, once started, it's really the instance that's running.
You can have one or more instances running that are derived from an image (AMI). Here is a good little tutorial, that's a bit old mind you, talking about how you can convert an Instance to an AMI ... which you can then redeploy one or many times:
http://webkist.wordpress.com/2010/03/16/creating-an-amazon-ec2-ebs-ami-from-a-running-instance/
What is an AMI: Amazon Machine Image
http://en.wikipedia.org/wiki/Amazon_Machine_Image
Technically, you can't start an AMI. You can start an instance that is derived from an AMI.
Amazon's new EBS-based EC2 instances have two options to shutdown: terminate or stop. Stopped instances can be later started again, automatically continuing from the same EBS root disk state they had when they were stopped.
But what happens when an Amazon datacenter has a hardware failure, and the EC2 instance is forced to shutdown. Does it terminate or stop? If the instance has been configured to stop by default on shutdown, can I rely on it being stopped also in this situation, and being able to start it again later?
An EC2 instance can be terminated at any time and one must account for this indeed, as already mentioned in David's answer (+1). You can arrange for a failed instance's Elastic Block Store (EBS) to remain available regardless though, see e.g. the respective FAQ What happens to my data when a system terminates?:
The data stored on a local instance store will persist only as long as
that instance is alive. However, data that is stored on an Amazon EBS
volume will persist independently of the life of the instance. If you
are using an Amazon EBS volume as a root partition, then you have set
the Delete On Terminate flag to "N" for your Amazon EBS volume to
persist outside the life of the instance. [emphasis mine]
This is explained in more detail in section 2. Delete on Termination within Eric Hammond's recommended article Three Ways to Protect EC2 Instances from Accidental Termination and Loss of Data:
Though EBS volumes created and attached to an instance at
instantiation are preserved through a “stop”/”start” cycle, by default
they are destroyed and lost when an EC2 instance is terminated. This
behavior can be changed with a delete-on-termination boolean value
buried in the documentation for the --block-device-mapping option of
ec2-run-instances.
He is referring to the ec2-run-instances documentation, and all this is meanwhile illustrated in more detail within Amazon EC2 Root Device Storage Concepts as well:
By default, the root device volume and the other volumes created when
an Amazon EBS-backed instance is launched are automatically deleted
when the instance terminates [...]. You can change
the default behavior by setting the DeleteOnTermination flag to the
value you want when you launch the instance. For an example of how to
change the flag at launch time, see Using Amazon EC2 Root Device Storage.
I assume you mean the CPU related hardware fails, rather than the network disk. The way I treat EC2 is to create a system that can go up and down without data loss. Anything important you should use an S3 bucket, not EBS.