Using Powershell launching a Server 2012 R2 machine. I can launch an instance from the stock Server 2012R2 AMI with a defined new EBS volume for d: drive, and upon boot, is online, and works fine.
If I take the same code and just add creation of the volume from snapshot, it boots, the volume is there, but it is shown OFFLINE. Once in disk manager, mark it online and all is again well and I have a D: drive.
I tried several different ways to create the snapshot (running, offline, detached, instance stopped). Nothing seems to make a difference.
EDIT: Also tried launching instance without volume, provisioning volume, and attaching it to instance. Same results
Thoughts?
Thanks
Cam
Code I'm using:
#configure D:\ drive
$Volume2 = New-Object Amazon.EC2.Model.EbsBlockDevice
$Volume2.DeleteOnTermination = $True
$Volume2.VolumeSize = 10
$Volume2.VolumeType = "gp2"
$Volume2.SnapshotId = "snap-xxxxxx"
#and map it
$Mapping2 = New-Object Amazon.EC2.Model.BlockDeviceMapping
$Mapping2.DeviceName = 'xvdf'
$Mapping2.Ebs = $Volume2
#create the instance
$NewInstance = New-EC2Instance -ImageId $ImageId -MinCount 1 -MaxCount 1 -InstanceType "t2.medium" -SecurityGroupIds xxxx -SubnetId xxxxx -UserData $UserdataBase64Encoded -KeyName XXX -AvailabilityZone us-east-1c -BlockDeviceMapping $Mapping2