Windows EC2 => snapshot => AMI => new EC2 doesn't work - amazon-web-services

I am very new to AWS. I had a perfectly running Windows Server EC2 on t2.micro. IIS is working perfectly and I can get its HTML using a web browser. I can RDP into it.
I then stopped it, created a snapshot from its only EBS volume.
I then created an AMI from the snapshot.
I then launched the AMI. What is interesting is t2.micro is not available. Only t1.micro and m3.medium onward are available. When I tried to launch, it warns me that port 22 is not turned on so I can't remote into it. The instance status check says "insufficient data". When I clicked the "Connect" button, it asks me to use putty. So it seems to think that the instance is a Linux instance. But I have redone this whole process five times and under no circumstance I ever chose Linux.
If I skip the snapshot, and directly create an AMI from the EC2 instance and launch it, t2.micro is available, and the new instance works.
Why can't I create an AMI from snapshot, if AWS provides such functionality?

Snapshot is a backup of your data.
AMI is snapshot of your system.It contains the bootable information like
the architecture, kernel, block device mappings ,instance type etc. , so that it will have some information prior to instance launch.

It is not possible to create an AMI image of a Windows-based EC2 instance from an EBS snapshot. That process:
EC2 instance -> EBS snapshot -> AMI image -> EC2 instance
only works for Linux instances.
To create a working AMI image from a Windows EC2 instance, you must use the "Create Image" function from the source EC2 instance directly:
Via AWS Management Console: Actions -> Image -> Create Image
Via API: ec2:CreateImage
Via CLI: aws ec2 create-image

Related

How can I bundle a aws ec2 windows machine with installed applications

I have a ec2 windows machine with adobe after effects running. I am trying to create a template from this ec2 instance which should allow me to launch new ec2 windows instances with adobe after effects already being preinstalled. However, it looks like that is not possible. The option to "bundle instance" is greyed out. Or have I misconfigured the ec2 template?
"Bundle" commands are outdated.
You should simply use Create Image to create an Amazon Machine Image (AMI) of the existing instance. Then, you can Launch an instance from the AMI and it will contain an exact copy of the AMI.
See: Creating a Custom Windows AMI - Amazon Elastic Compute Cloud
Recommendation: Run sysprep before creating the image. This will avoid conflicting machine IDs.
See: Create a Standard Amazon Machine Image Using Sysprep - Amazon Elastic Compute Cloud

EBS Volume attach to running EC2 Windows instance

I am having a scenario where EC2 mount two EBS Volumes and one of them is root. My ELB is setup to size=1 instance actively running. I want to have second EBS volume snapshot to be attached to new EC2 spin-off using AMI. How to do it using CloudWatch Event and Lambda?
EC2 API for volume mount do not specify windows mounts. Any Idea how to support EC2 Windows mounts using Lambda Function or any other scripting technique?
EDITED -
Here is what is expected - I have secondary EBS volume mounted to EC2 Windows. I have taken AMI of this machine and associated with Auto Scaling Group and Launch Configuration. In case of DR, ASG spins off new EC2 instance using defined AMI. It is desired that this new spin off machine to use same secondary EBS volume from snapshot.
Just mount the volume as normal. It is supported for both Linux and Windows.
If you are worried about the Linux-like device name, see Device Naming on Windows Instances - Amazon Elastic Compute Cloud:
Recommended for EBS Volumes: xvd[f-z]
An Amazon Machine Image (AMI) can contain multiple volumes.
I suggest you:
Launch an Amazon EC2 instance with both desired volumes (Root + Volume X:)
Create a new AMI from that instance, specifying both volumes
Create a new Auto Scaling launch configuration using that new AMI
Edit the Auto Scaling group to use the new Launch Configuration

Effect of EC2 config change on EBS-backed Wordpress?

I am deploying Wordpress site using LAMP AMI on EBS-backed EC2. Wordpress database will be stored in EBS.
Amazon keeps on updating base configuration of EC2 for better performance & security.
If I have to upgrade my EC2 then my EBS will get deleted.
How can I ensure that my EC2 gets updated without affecting my EBS?
EBS Snapshot is not of any help as new EC2 already has a EBS attached.
Do I have to always migrate my Wordpress site using backup & do this upgradtion?
Amazon EC2 instances use EBS volumes as their disk volumes. They are populated from an Amazon Machine Image (AMI) when the instance is launched.
When AWS releases updated AMIs, any new instance launched from the AMI will contain the updated disk content. However, existing EC2 instances will not be changed (since they have a copy of the AMI at the time that the instance was launched).
You can also change the Instance Type of an EC2 instance, which gives it different hardware (CPU, Memory). This can be done by stopping the instance, changing the type and starting it again. This will not affect the contents of EBS volumes.
If you wish to keep your instance "current", simply run sudo yum update (Linux) or run the Windows Update utility to update your operating system and associated utilities rather than launching a whole new instance.

How to use t2.nano ec2 instances in an Amazon ec2 container cluster?

The cluster wizard's dropdown menu only shows t2.micro or larger instances.
I want to use a t2.nano instance to run my docker image.
Can this be achieved while using the ec2 container service?
I know that can manually setup my own t2.nano ec2 instance and run the docker pull and run commands manually from there. Basically use the AWS EC2 Container repository, but not the Clusters or Task Definitions functionality.
They probably missed this instance type in the console wizard. You can launch the EC2 instance yourself (I recommend you to use an AutoScaling Group even if it's one instance) and then run the ECS agent on the instance. You don't have to do much if you pick the ECS-optimized AMI that AWS provides.
You can launch the EC2 instance from the AMI manually, but I recommend you to:
create a Launch Configuration using the latest ECS-optimized AMI and change the user data to be: #!/bin/bash
echo "ECS_CLUSTER=your-cluster-name-here" > /etc/ecs/ecs.config
create an AutoScaling group and set the proper desired capacity
Check if your Cluster got the new instance once the instance is up and healthy
More info:
http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-optimized_AMI_launch_latest.html
http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-install.html

Stopping AWS EC2 instance leads to autocreation of another instance of the stopped one

I had to stop my m3.medium EC2 instance from the AWS console to resize it to m3.large. However, after it stopped, it automatically created a new instance.
Any idea why this is happening? It caused some big troubles for me.
Your AutoScaling group with minimum size = 1 spun up a new instance because there were no instances in the 'running' state available to respond to requests, particularly health checks. Your instance was deemed 'unhealthy' and replaced by the ASG.
If your instance storage was ephemeral, I'm afraid it is gone forever unless you recently saved an AMI. If your instance storage was backed by EBS, you can recover it by attaching the EBS volume to a new instance.
In the future, consider configuring your autoscaling group's launch configuration to have everything you need ahead of time, by either bootstrapping the instance or by baking an AMI.
For 'bootstrapping' an instance:
Create a new launch configuration with a standard AMI avaialble from Amazon.
Add user data to the launch configuration to handle installation and configuration of your desired programs.
For 'baking' an AMI:
Install your desired programs and configuration on a new EC2 instance.
Take an image (AMI) of that EC2 instance.
Use that image in your new launch configuration.
Manually working on an instance within an ASG and expecting the instance to persist indefinitely is dangerous, as you've just discovered.
Further Reading:
EC2 Documentation - AutoScaling Health Checks
EC2 Documentation - Amazon Machine Images