I want to use the new "gp2" volume type as the boot volume for my Windows instances, with an out-of-the-box Windows AMI from Amazon (e.g. ami-527b823a), and the AWS SDK for .NET (v2.1.7 - latest as of 9-July-2014). How do I configure my run-instances request?
Based on the post on the AWS blog, I tried setting a BlockDeviceMapping:
new RunInstancesRequest {
...
BlockDeviceMappings = {
BlockDeviceMapping {
DeviceName = "sda1",
Ebs = new EbsBlockDevice { VolumeType = VolumeType.Gp2 }
},
new BlockDeviceMapping {
DeviceName = "xvdf",
Ebs = new EbsBlockDevice {
SnapshotId = SNAPSHOT_ID
DeleteOnTermination = true,
VolumeType = VolumeType.Gp2
}
}
...
}
}
But this didn't work, and I got an unsurprising exception:
Amazon.EC2.AmazonEC2Exception: The device 'sda1' is used in more than one
block-device mapping ---> System.Net.WebException: The remote server
returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
...
Is it possible to set the boot (root) volume of my windows instances to gp2? Or do I need to wait for a later release of the SDK?
Using the following code and version 2.1.7 of the AWS SDK for .NET, I was able to successfully launch with a GP2 EBS root volume:
BlockDeviceMapping mapping = new BlockDeviceMapping
{
DeviceName = "/dev/sda1",
Ebs = new EbsBlockDevice
{
VolumeType = VolumeType.Gp2,
VolumeSize = 30
}
};
var request = new RunInstancesRequest
{
BlockDeviceMappings = { mapping },
ImageId = "ami-527b823a",
InstanceType = InstanceType.M1Small,
MinCount = 1,
MaxCount =1
};
var ec2Client = new AmazonEC2Client(RegionEndpoint.USEast1);
ec2Client.RunInstances(request);