Tool for Resizing EBS Volumes

Tool for Resizing EC2 EBS Volumes

I recently had the need to resize a number of EBS root volumes connected to EC2 instances. I have released the tool that I wrote to do this – available at: ec2-modify-ebs-volume allows changing volume size, volume type (provisioned IOPS or standard) and volume IOPS.

Extending Python virtualenv using Bootstrap Scripts

Extending Python virtualenv with Bootstrap Scripts


extending a python virtual environment immediately after the virtual environment has been created. The virtualenv documentation refers to this as bootstrapping. For those who are hands-on, I’ve included a link to a zip file containing the scripts described in this post.

Most typically “bootstrapping” would be used when describing running a Python application within a virtual environment. As an example this might entail:

  1. creating a virtual environment my_app
  2. installing the modules boto and mysql-connector-python
  3. running after modules have been installed

Possible Solutions:

  1. Using a shell script to create and then customize the virtual environment. For the impatient:
  2. Using a virtualenv “Bootstrap Scripts” that runs “after_install” once an environment has been created. For the impatient: my_app

Shell Script Bootstrapping:

To test the shell script method of bootstrapping I created a simple shell script that does the following:

  1. creates a virtual environment named my_app
  2. activates the my_app virtual environment
  3. installs additional modules in my_app using pip
  4. runs

virtualenv Bootstrapping:

The authors of virtualenv have provided a means of bootstrapping virtual environments through the creation custom virtualenv “bootstrap scripts” and the injection of three functions into these scripts. The three functions are listed below:

  • extend_parser
  • adjust_option
  • after_install

Customizing a virtual environment required only that I utilize the “after_install” function – after_install met my need of installing modules after the virtual environment has been created. I wanted to experiment with bootstrap scripts and after_install further, so I devised two tests.

Test 1: Creation of a Default Bootstrap Script (no after_install)
Test one was to simply create a default virtualenv bootstrap script using the virtualenv function “create_bootstrap_script.” I did this utilizing a script called The resulting bootstrap script (named is nearly the same as I diff’ed both and – there are no meaningful differences.

Test 2: Creation of a Custom Bootstrap Script (using after_install)
Test two had one objective:

  1. customize the newly created my_app virtual environment by adding python modules after install.

Having worked with virtualenv bootstrap scripts before and been frustrated with “including a script in a script”, I added additional objectives:

  1. provide the ability to create and update the after_install script and then inject it into the bootstrap file
  2. provide output to standard out notifying the user that after_install had been called

My solution was to create a script (named: that did the following:

  1. read an after_install script – by default this is
  2. insert this into the default virtualenv bootstrap script as an after_install function
  3. write out the resulting bootstrap file as’s function is described in the diagram below:


In Summary:

  • Either shell script or after_install method of bootstrapping worked equally well.
  • The shell script method is easier to learn and troubleshoot.
  • Those implementing virtualenv functionality may wish to look at