The ec2-create-image
command line tool has a --block-device-mapping
option to define the volumes associated with new instances.
http://docs.amazonwebservices.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-CreateImage.html
In your specific case, you may want to suppress the automatic creation and attaching of the database volume by specifying something like:
ec2-create-image --block-device-mapping /dev/sdh=none [...]
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:
ec2-create-image --block-device-mapping /dev/sdh=:20:false [...]
When you run an instance, you could override the size of that volume using the --block-device-mapping
option to ec2-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.