Is it possible to create an EBS AMI for windows EC2 instance?
Solution 1:
Background
Launching an Instance from a Snapshot is not available for Windows AMIs (as you have meanwhile discovered yourself):
Important
Registering a snapshot works only for Linux/UNIX AMIs; although you can register a snapshot to create a Windows AMI, the AMI isn't launchable. [emphasis mine]
Alternative
While not specified, one should be aware of the possibility to simply clone an Amazon EBS-Backed Instance as outlined in Creating an Image from a Running Instance - when doing this via the AWS Management Console like so, EC2 attempts to cleanly shut down the instance before image creation and reboots the instance afterwards. This is obviously generally preferable, however, it can be avoided via the command line, if so desired:
If you prefer the instance not be rebooted, you can use the Amazon EC2 command line tools to create the image [...]. The ec2-create-image command has a --no-reboot option.
Solution
The alternative approach mentioned above obviously won't help to create a new EC2 instance from one of these snapshots as specified - a solution useful to be aware of anyway is outlined in section Moving to a New Instance of Eric Hammond's article Move a Running EBS Boot Instance to New Hardware on Amazon EC2 (which has a different use case, but applies regardless) and boils down to these steps in your case:
- Create a new instance with the same startup parameters as the original one.
- Wait until the new instance is running and then stop (not terminate) it.
- Detach the EBS boot volume from the new instance and delete this detached volume, as it is not required anymore.
- Create a new volume from the snapshot and attach it to the new instance.
- Restart the new instance which is now going to boot with the volume created from your snapshot.
This technique has been used by Colin Percival to enable running FreeBSD on EC2 via defenestration as well btw. (which includes some hints towards the virtualization issues):
EC2 Windows instances, on the other hand, are launched in HVM (Hardware Virtual Machine) mode — which FreeBSD supports very well. If we can somehow trick EC2 into launching FreeBSD the same way as it launches Windows, we can run FreeBSD on a wide range of instance types. How can we trick EC2? Take advantage of the fact that Elastic Block Store disks can be detached from EC2 instances and reattached to different instances, and replace the boot disk of a "Windows" instance with a disk containing FreeBSD.
Solution 2:
I have discovered that you can create an AMI only from the instance, not from existing snapshots. The commands to create an AMI from snapshots only support linux.
The command line command to create an AMI from a windows instance (running or stopped) is ec2-create-image
. I've successfully done this using the ruby sdk. The command creates snapshots of the EBS volumes attached to the instance and then constructs the correct AMI using those snapshots. If you use the web console, it will shut the windows machine down. From command line / api you have a choice of not shutting it down, in which case you need to take the same care for data consistency as you would with making a snapshot anyway.
So if you have terminated your instance and don't have an AMI, you're up the creek. Alternatively you could start a new windows instance, and shut it down and then connect volumes made from your snapshots. I haven't tried this yet, but I would hope you can detach the boot volume and attach a new one.