I have an EBS-backed instance with a 2nd mounted volume (I followed the steps in Eric's Article)
I then created an AMI from that instance, and ran an instance from that AMI.
That 2nd instance then created two volumes.
Is there a way to control how the volumes associated with with an AMI are created, or is the solution just to unmount the 2nd volume before creating the AMI?
The
ec2-create-image
command line tool has a--block-device-mapping
option to define the volumes associated with new instances.In your specific case, you may want to suppress the automatic creation and attaching of the database volume by specifying something like:
This will let you create and attach your own volumes to the new instances.
Alternatively, you could specify that an empty volume be created an attached when a new instance is started:
When you run an instance, you could override the size of that volume using the
--block-device-mapping
option toec2-run-instances
.It's also worth learning about the
delete-on-termination
flag for--block-device-mapping
so that you understand how to control whether your second volume should automatically be deleted when the instance is terminated.