Amazon AWS snapshot vs. volume

We stop and start AWS EC2 instances.  We have created our own private AMI.  All good.
Problem is that we'd like each instance to be configured with slightly different files.

When we launch the "standard AMI", it seems that the additional drive is included in the AMI -- we can't seem to find a way to select a "volume" afterwards.

In other words, we'd like to attach a "D:" drive that we choose.   Machine1, based on our StandardAMI,  would get the volumeA this week...  next time we launch Machine1 we could select volumeB.

Could someone please walk me through that?
LVL 2
Francois KoutchoukCTOAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shalom CarmelCTOCommented:
Create your AMI without the D: drive attached, and then see this explanation how to attach a volume to a windows server.

http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ebs-attaching-volume.html
http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ebs-using-volumes.html


There is a nice script on Stackoverflow that accomplishes the attaching part automatically, while pulling the volume to use from the instance user defined metadata.

http://stackoverflow.com/questions/328965/automount-ebs-volume-in-amazon-ec2-windows-instance

REM Originally from http://stackoverflow.com/questions/328965/automount-ebs-volume-in-amazon-ec2-windows-instance 
REM @echo off
REM setlocal ENABLEDELAYEDEXPANSION

C:\WINDOWS\system32\eventcreate /l SYSTEM /t information /id 100 /so AttachEbsBoot /d "Starting attach-ebs-boot.cmd"

REM local variables
REM Make sure you include the directory with curl.exe and the EC2 command line tools in the path
set path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Utils;C:\ebin\ec2\bin
set JAVA_HOME=c:\java
set EC2_HOME=c:\ebin\ec2
set EC2_CERT=<your_cert>
set EC2_PRIVATE_KEY=<your_private_key>

REM Please note: you should use the Ec2 Config Serive Settings application to ensure
REM that your EBS volume is mapped to a particular drive letter.
REM
REM edit as needed
set EBS_DRIVE=P:
set EBS_DEVICE=xvdp

REM Test to see if the drive is already attached. If it is then we're done.
if exist %EBS_DRIVE%\nul (goto done)

REM get the EBS volume ID from the user data and the instance ID from the meta-data
for /f "delims=" %%a in ('curl http://169.254.169.254/latest/user-data') do (set EBS_VOLUME=%%a)
for /f "delims=" %%b in ('curl http://169.254.169.254/latest/meta-data/instance-id') do (set INSTANCE_ID=%%b)

C:\WINDOWS\system32\eventcreate /l SYSTEM /t information /id 102 /so AttachEbsBoot /d "Volume == %EBS_VOLUME%"
C:\WINDOWS\system32\eventcreate /l SYSTEM /t information /id 103 /so AttachEbsBoot /d "Instance == %INSTANCE_ID%"

REM attach the volume
REM 
REM Use a series of set command to build the command line
SET COMMAND_LINE=%EBS_VOLUME%
SET COMMAND_LINE=%COMMAND_LINE% -i
SET COMMAND_LINE=%COMMAND_LINE% %INSTANCE_ID%
SET COMMAND_LINE=%COMMAND_LINE% -d
SET COMMAND_LINE=%COMMAND_LINE% %EBS_DEVICE%

C:\WINDOWS\system32\eventcreate /l SYSTEM /t information /id 104 /so AttachEbsBoot /d "calling ec2attvole %COMMAND_LINE%"

call ec2attvol.cmd %COMMAND_LINE%

:DONE
C:\WINDOWS\system32\eventcreate /l SYSTEM /t information /id 101 /so AttachEbsBoot /d "Exiting attach-ebs-boot.cmd"

REM Events logged in the System event log
REM source === AttachEbsBoot
REM 
REM Event 100 - Script start
REM Event 101 - Script end
REM Event 102 - Volume ID
REM Event 103 - Instance ID
REM Event 104 - Command line for ec2attvol

Open in new window

0
Francois KoutchoukCTOAuthor Commented:
Great, thank you.  I can see that I can start an instance, attach/force-detach a volume.
Now what I would like is to "copy" a Volume.
I see that I can "Copy" a snapshot --> but no option to create a New Volume from that snapshot
I don't see the option to copy a volume.

The idea is:  machine1 put all its configuration on the attached D: drive.  I want machine5 to now use that.  I would briefly force detach the D: drive, make a quick copy, then attach back to machine1, then attach the new copy to machine2.
0
Stuart ScottAWS Trainer at Cloud AcademyCommented:
Hi,

You can create a new volume from a snapshot - See the link below on how to do this.

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-restoring-volume.html

OR

- Go to your AWS Console
- Select "EC2"
- Go to "Snapshots" under "Elastic Block Store"
- Select the Snapshot you want to create a volume from
- Select "Actions"
- Select "Create Volume"

Hope this helps,

Cheers,

Stuart...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
AWS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.