README: volume-attacher - attaches EBS volumes to instances, switching and deleting old ones if needed License: You can use/modify/circulate or do whatever you want. Just note that this script is given "As Is" without any warranty Requirements: Needs python 2.7.3 or newer (not python 3) boto library (at least 2.24.0). Can be dowmloaded here: https://pypi.python.org/pypi/boto/#downloads usage: volume-attacher.py [-h] --instance INSTANCE --volume VOLUME --device DEVICE [--region REGION] [--access_key ACCESS_KEY] [--secret_key SECRET_KEY] [--force] {attach,switch,switchanddelete} Attaches EBS voluems to instances + switches with existing volumes. positional arguments: {attach,switch,switchanddelete} optional arguments: -h, --help show this help message and exit --instance INSTANCE EC2 instance ID to perform the action on --volume VOLUME EBS volume ID to attach --device DEVICE device to use when attaching the volume to the instance --region REGION AWS region the instance is in. If missing default is used --access_key ACCESS_KEY AWS API access key. If missing default is used --secret_key SECRET_KEY AWS API secret key. If missing default is used --force If set, this flag will prevent confirmation for the action Actions: attach - simply attaches an EBS volume to an instance, using specified device switch - will stop the instance, detach any volume that is attached to specicied device, attaches the new volume instead, and starts the instance switchanddelete - will stop the instance, detach any volume that is attached to specicied device, deletes the old volume, attaches the new volume instead, and starts the instance Defaults: At the top of the script there are 3 default definitions: AWS_ACCESS_KEY - default access key. If the scripts runs on an instance with a sufficient IAM role, it can be left as None and will work. If not can be switched to AWS_ACCESS_KEY = 'AKIAIVXXXXXXN3G3N32Q' AWS_SECRET_KEY - default secret key. If the scripts runs on an instance with a sufficient IAM role, it can be left as None and will work. If not can be switched to AWS_ACCESS_KEY = 'UGSYQL6PXXXXXXXXXX0Bf0bS/S+OwnA2GrJ0MOY4Y' AWS_REGION - defualt region in case --region is dropped. example: AWS_REGION = u'us-east-1' Examples: python volume-attacher.py --access_key AKIAIVKXXXXXXXG3N32Q --secret_key UGSYQL6XXXXXXXXXXXX0bS/S+OwnA2GrJ0MOY4Y --volume vol-dxx2129c --instance i-16xx3f38 --device /dev/sdb --force switch python volume-attacher.py --access_key AKIAIVKXXXXXXXG3N32Q --secret_key UGSYQL6XXXXXXXXXXXX0bS/S+OwnA2GrJ0MOY4Y --volume vol-dxx2129c --instance i-16xx3f38 --device /dev/sdb switchanddelete