My company want to take daily snapshots of a windows in Amazon Web Service. We can take snapshot without any issue but when I try to create instance from snapshot, it always creates a linux ami. so when the server starts, it always fails the health check.
Is it possible to create a windows instance from a snapshot?
[Please note that I'm assuming you are using EBS-Backed EC2 instances; if not, please check Eric Hammond's explanation why You Should Use EBS Boot Instances on Amazon EC2.]
It sounds like there might be a misunderstanding regarding the related AWS concepts:
While Amazon EBS snapshots are indeed utilized for the creation of an Amazon Machine Images (AMI) under the hood, you do not explicitly interact with them for the use case at hand. Specifically, you don't want to use CreateSnapshot, which only Creates a snapshot of an Amazon EBS volume and stores it in Amazon S3, rather you want to simply create such an AMI via the dedicated action CreateImage, which Creates an Amazon EBS-backed AMI from an Amazon EBS-backed instance that is either running or stopped [emphasis mine]:
This process is outlined in Creating Amazon EBS-Backed AMIs (while this section addresses creating a 'new' AMI, the process is identical to your backup scenario).
Please note that CreateImage automatically takes care of additional EBS volumes attached to your instance as well, if any:
If you customized your instance with instance store volumes or EBS volumes in addition to the root device volume, the new AMI contains block device mapping information for those volumes. When you launch an instance from this new AMI, the instance automatically launches with those additional volumes.
Once you have an image (AMI) generated like so in place, creating your Amazon EC2 instance from that AMI should work out as desired, be it a Windows or Unix one.
try this
var launchRequest = new RunInstancesRequest()
{
ImageId = amiID,
InstanceType = ConfigurationManager.AppSettings["AwsInstanceType"],
MinCount = 1,
MaxCount = 1,
KeyName = keyPairName,
SecurityGroupIds = groups,
SubnetId = ConfigurationManager.AppSettings["AwsSubnetId"],
};
RunInstancesResponse runInstancesResponse = amazonEc2client.RunInstances(launchRequest);
var InstanceId = runInstancesResponse.Reservation.Instances[0].InstanceId;
var trequest = new CreateTagsRequest();
trequest.Resources=new List<string>(){InstanceId};
List<Tag> tags=new List<Tag>();
Tag tag=new Tag("Name","TestCodeFinal");
tags.Add(tag);
trequest.Tags = tags;
amazonEc2client.CreateTags(trequest);
Reservation reservation = runInstancesResponse.Reservation;
Related
I create an instance but do not add additional storage / a volume, will a snapshot backup the instance and the changes I have made to the config or does it only backup data from the volumes?
I am making some training material and would like to do the following:
Create an instance
Create users
Make a few more config/program installation changes
At this point, I would have a "clean copy".
I then would like to take a Snapshot of the state of the instance.
fool around, possibly break stuff
Then restore the instance to the "clean copy" after the instance has been created but before I started messing around.
Is this possible with snapshots?
Let's clarify some terminology:
A Snapshot can be made of an Amazon EBS volume. This makes a backup of the specific disk volume. The snapshot can be used later to create a new EBS Volume.
Or, you can create an Amazon Machine Image (AMI) of an Amazon EC2 instance. This creates an EBS Snapshot of all associated volumes and also stores some metadata about the AMI.
You can then Launch a new Amazon EC2 instance from the AMI. This will include a copy of the disks.
If you wish to restore the instance to the "clean copy", then it is best to launch a new instance from the AMI rather than trying to 'reset' the instance to an earlier state. The instance will have a different Instance ID and a different IP address, but will otherwise be the same as the instance from which the AMI was created.
We have used Elastic Beanstalk for creating the EC2 instances. Is it possible to screate the new EC2 instance with the existing EC2 instance image, when the existing EC2 instance is getting terminated in any case? Can we achieve this by any configuration?
I don't think this is possible.
As soon as you send a terminate request on your EC2 instance, the IP and hardware (disk and other resources) are released.
If you are trying to do this programmatically, I'd suggest you create an AMI before sending a terminate request.
You can create an AMI from the EC2 before you terminate it, and then create a new Elastic Beanstalk environment using this AMI. However, it's not advisable as you'll lose future version upgrades of that AMI as performed by Amazon.
I advise you use the .ebextensions folder mechanism supplied by Elastic Beanstalk in order to alter new instances as they are spawned (see documentation).
I have an EBS-backed AMI instance running in EC2. I have customized it and now want to create a new AMI from it. I will doing this at regular intervals, thereby replacing the previous AMIs created.
I followed the instructions at
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-ebs.html
and everything worked perfectly.
One problem is that whenever, I create a new AMI, it gets a new AMI ID. So, when I make the AMI public whenever, I update the AMI, it's AMI ID changes. Is it possible to create a new AMI with a custom ID we can specify?
One alternative would be modify an existing AMI, so that the AMI ID remains the same. Please confirm if this is possible
Each time you create a new AMI, you will get a new id. There is unfortunately no way around this.
An alternative would be to update some of the AMI at launch, provided that it can be done relatively quickly. That way you wont need to create a new AMI every time something changes.
It is not possible to modify the contents of an AMI once you have created it such that the next time the AMI is used those changes will be present. This includes the root device and any data in EBS snapshots associated with the AMI (since it's not possible to alter the contents of an EBS snapshot, either).
Due to system crash after update i set up new instance with ebs(old instance has an instance store). But i need to copy some data form old instance to new. It`s possible to mount instance store from old instance to new? How to do this?
Have you come across this thread: Mounting Old EBS Volume to the new Instance - Amazon EC2
I'm not sure if that's what you're looking for, but the answer on that thread details the process of mounting the old EBS volume to the new one on an Amazon EC2 instance.
I am new to Amazon web services. I need to create a server image with a few software packages pre installed on the EC2 instances.
One option I am considering is to create an EBS volume with these packages and then use them to launch EC2 instances.
The other option I am thinking of is to create a private AMI and then use them to launch the EC2 instances.
I am not sure which option is better.
One other slightly related question I have is can I create a private EBS volume and share it with some other account.
You should create your own AMI, as it's probably more efficient. In order to create an instance, you must specify an AMI. Specifying an EBS snapshot as the root device in addition to specifying the AMI (if this even works, I haven't tested it) would just result in the EC2 cloud launching your instance with the AMI, followed by overwriting it with the EBS snapshot for the root volume.
It's easy enough to keep the AMIs laying around as prototypes.