EC2 Instance Retirement - Just restart or launch new instance from AMI? - amazon-web-services

I have received an email about an EC2 instance that is to be retired on the 1/12/2015. I can provide more details on the case if need be. I have gone through this process before (approx a year ago), and it all went smoothly. The only difference this time is in the instructions. Last time, according to the instructions, all I had to do, was just restart my instance. Now, I have to create an AMI from my instance, and launch a new instance with that AMI. Please, note that in both cases my instances were/are EBS backed.
Do I really need to create an AMI and launch a new instance or just restarting the instance would do? Please, keep in mind, that I need to keep my EBS data intact.
Cheers,
Iraklis

From the AWS EC2 documentation:
Managing Instances Scheduled for Retirement
You can perform one of the actions listed below in order to preserve
the data on your retiring instance. It's important that you take this
action before the instance retirement date, to prevent unforeseen
downtime and data loss.
Warning If your instance store-backed instance passes its retirement
date, it's terminated and you cannot recover the instance or any data
that was stored on it. Regardless of the root device of your instance,
the data on instance store volumes is lost when the instance is
retired, even if they are attached to an EBS-backed instance.
An instance is scheduled to be retired when AWS detects irreparable
failure of the underlying hardware hosting the instance. When an
instance reaches its scheduled retirement date, it is stopped or
terminated by AWS. If your instance root device is an Amazon EBS
volume, the instance is stopped, and you can start it again at any
time. Starting the stopped instance migrates it to new hardware. If
your instance root device is an instance store volume, the instance is
terminated, and cannot be used again.
Instance Root Device Type: EBS
Action: Wait for the scheduled retirement date - when the instance is
stopped - or stop the instance yourself before the retirement date.
You can start the instance again at any time. For more information
about stopping and starting your instance, and what to expect when
your instance is stopped, such as the effect on public, private and
Elastic IP addresses associated with your instance, see Stop and
Start Your
Instance.
Instance Root Device Type: EBS
Action: Create an EBS-backed AMI from your instance, and launch a
replacement instance. For more information, see Creating an Amazon
EBS-Backed Linux AMI.
Instance Root Device Type: Instance store
Action: Create an instance store-backed AMI from your instance using
the AMI tools, and launch a replacement instance. For more
information, see Creating an Instance Store-Backed Linux
AMI.
Instance Root Device Type: Instance store
Action: Convert your instance to an EBS-backed instance by
transferring your data to an EBS volume, taking a snapshot of the
volume, and then creating an AMI from the snapshot. You can launch a
replacement instance from your new AMI. For more information, see
Converting your Instance Store-Backed AMI to an Amazon EBS-Backed
AMI.

Related

Launching an Instance Store backed Instance

Just wanted to know, how can I launch an Instance Store Backed Instance, on the EC2 launch page I see all EBS backed AMIs. Don't see any Instance store backed AMI. Do I have to create an Instance Store Backed AMI first to launch an Instance Store backed instance.
You will need to use an instance store-backed AMI.
When launching an Amazon EC2 instance in the management console:
Select Community AMIs
For Root device type, select Instance store
Select a desired AMI
By the way, there is very little benefit these days in booting off instance store, compared to the benefits that EBS provides (start/stop, snapshots, resizing, etc).

An unknown AWS EC2 instance running which recreates even after termination

I am running amazon AWS ECS container which creates one single instance of EC2. I made sure that it is 1 instance when I created ECS.
My issue is that I have another instance running in EC2 and amazon has sent me an email that I am using double of the free quota and will be charged.
But I am not sure why this second EC2 instance is coming from.
I have terminated it many times but it is recreated. When I terminate it, this is the prompt i receive which advises me that it is created from EBS but there is no app in EBS
On an EBS-backed instance, the default action is for the root EBS volume to be deleted when the instance is terminated.
Storage on any local drives will be lost.
This name of the instance is.
ECS Instance - amazon-ecs-cli-setup-ecs-cricketscorer
Please help.
check if you have any Auto Scaling Groups that you do not recognize. It is most probably being created because of it. If not, change your account password and deactivate/delete your existing AccessKeys.

Backing up root device (mounted at /) of an AWS t2.micro instance running Ubuntu

I want to back up the root device (mounted at /) of my t2.micro instance running Ubuntu. I think the instance is EBS-backed as it is a t2 instance. So I was going to take snapshots of my root device to back it up.
However, it is recommended that I detach the root device before I back it up. There are two problems with this:
I have to use umount to unmount it first, which may cause my instance to crash. What is a safe way to handle this?
I want to run these backups as a cron job on the instance itself, but if my instance's root device is unmounted, will the cron job even run?
A more general question is: what is the best way to do this?
A possible solution might be: use AWS Lambda and execute a Lambda function based on a schedule executing the following commands by the use of the AWS SDK:
Stop EC2 instance
Create EBS snapshot
Start EC2 instance
First, I would confirm that your root device is in fact EBS backed.
Here are the basic steps to confirm:
To determine the root device type of an instance using the console
Open the Amazon EC2 console.
In the navigation pane, click Instances, and select the instance.
Check the value of Root device type in the Description tab as follows:
If the value is ebs, this is an Amazon EBS-backed instance.
If the value is instance store, this is an instance store-backed instance.
(Source: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/RootDeviceStorage.html#display-instance-root-device-type)
AWS states as a best practice is to use snapshots or a backup tool.
Regularly back up your instance using Amazon EBS snapshots or a backup
tool.
(Source: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-best-practices.html)
AWS states in the documentation that root EBS volumes should be shutdown before taking a snapshot.
To create a snapshot for Amazon EBS volumes that serve as root
devices, you should stop the instance before taking the snapshot.
(Source: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-creating-snapshot.html)
So depending on your RPO (Recovery Point Objective), as a general rule it is a good practice to separate your data from your root volume. Store data that you need to keep on a separate EBS volume and take snapshots on the second EBS volume. This way you never have to worry about the instance itself - if it bonks out just launch a new instance and attach your snapshot.
If you have a special case that prevents you from using EBS snapshots, try using a role for your instance(s) that have permissions to read/write data to S3 buckets using your cron job.

AWS: Convert t1.micro (PV) to t2.medium (HVM)

I have t1.micro (PV) and I am trying to update (resize) to t2.medium (HVM).
However, when I created AMI from t1.micro and tried to attach to t2.medium, I did not get instance under list. So could not attached AMI to t2.medium.
So may I know how can I attached AMI to new instance from EC2 Console? Also, how can I take care of SSH , SSL , Cron , multi domains while migrating?
Resource I refereed: http://www.nixhat.com/2014/01/migrate-aws-pv-to-hvm-instance/
Thanks
I think you are misunderstanding the directions on that page. Let me highlight part of it.
Launch any HVM based centos.
Create a volume snapshot from your PV based instance
Attach the snapshot to the HVM
Copy kernel and other boot files from HVM to PV snapshot volume
Stop the instance
Detach root disk from HVM
Attach the PV snapshot to the instance as root device
Launch the instance
Note you are not attempting to launch your PV instance on a t2 machine, you are launching a new HVM instance. You are responsible to find and copy any configuration that you've changed, such as crons and configuration.
Note this question goes against the principle of "treat your servers like cattle, not pets". It appears you don't have a way to recreate your server/configuration from scratch, which should be a red flag- instances go down, people accidentally break their configuration, and so on.

What data is stored in Ephemeral Storage of Amazon EC2 instance?

I am trying to stop a Amazon EC2 instance and get the warning message
Warning: Please note that any data on the ephemeral storage of your instance will be lost when it is stopped.
My Question
What data is stored in ephemeral storage of an Amazon EC2 instance?
Basically, root volume (your entire virtual system disk) is ephemeral, but only if you choose to create AMI backed by Amazon EC2 instance store.
If you choose to create AMI backed by EBS then your root volume is backed by EBS and everything you have on your root volume will be saved between reboots.
If you are not sure what type of volume you have, look under EC2->Elastic Block Store->Volumes in your AWS console and if your AMI root volume is listed there then you are safe. Also, if you go to EC2->Instances and then look under column "Root device type" of your instance and if it says "ebs", then you don't have to worry about data on your root device.
More details here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/RootDeviceStorage.html
Anything that is not stored on an EBS volume that is mounted to the instance will be lost.
For example, if you mount your EBS volume at /mystuff, then anything not in /mystuff will be lost. If you don't mount an ebs volume and save stuff on it, then I believe everything will be lost.
You can create an AMI from your current machine state, which will contain everything in your ephemeral storage. Then, when you launch a new instance based on that AMI it will contain everything as it is now.
Update: to clarify based on comments by mattgmg1990 and glenn bech:
Note that there is a difference between "stop" and "terminate". If you "stop" an instance that is backed by EBS then the information on the root volume will still be in the same state when you "start" the machine again. According to the documentation, "By default, the root device volume and the other Amazon EBS volumes attached when you launch an Amazon EBS-backed instance are automatically deleted when the instance terminates" but you can modify that via configuration.
To be clear and answer #Dean's question: EBS-type root storage doesn't seem to be ephemeral. Data is persistent across reboots and actually it doesn't make any sense to use ebs-backed root volume which is 'ephemeral'. This wouldn't be different from image-based root volume.
For EC2 instance
Stop & Start != Reboot
so for ephemeral storage (Instance Store)
Stop cause data lost
Reboot will not
According to AWS documentation [https://aws.amazon.com/premiumsupport/knowledge-center/instance-store-vs-ebs/] instance store volumes is not persistent through instance stops, terminations, or hardware failures.
Any AMI created from instance stored disk doesn't contain data present in instance store so all instances launched by this AMI will not have data stored in instance store. Instance store can be used as cache for applications running on instance, for all persistent data you should use EBS.
ephemeral is just another name of root volume when you launch Instance from AMI backed from Amazon EC2 instance store
So Everything will be stored on ephemeral.
if you have launched your instance from AMI backed by EBS volume then your instance does not have ephemeral.
refer: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes
The data in an instance store persists only during the lifetime of
its associated instance. If an instance reboots (intentionally or
unintentionally), data in the instance store persists. However,
data in the instance store is lost under any of the following
circumstances:
- The underlying disk drive fails
- The instance stops
- The instance hibernates
- The instance terminates