I’ve been using AWS Opsworks with Chef for most projects these days, but started looking at Elasticbeanstalk again on a recent project. It took a little bit to get my head around the Elasticbeanstalk way of doing stuff like server setup, configuration, etc. but it seems like there are a lot more configuration options available then when I first used it years ago.

If you aren’t already familiar with it, Elasticbeanstalk looks in a folder called .ebextensions for configuration commands, files, etc. The files and the directives inside them get processed in alphabetical order and so a nn_purpose.config file naming convention seems to the norm.

The project I’m deploying is a node.js project that uses the zmq node library. That means I first need to get Zeromq packages installed on my instances before I can have the eb deploy attempt run npm install on the node dependencies.

According to the Elasticbeanstalk Advanced Environment Configuration documentation:

You can use the commands key to execute commands on the EC2 instance. The commands are processed in alphabetical order by name, and they run before the application and web server are set up and the application version file is extracted.

Sounds like exactly what we need!

This made the solution pretty simple; create a file called packages.config inside .ebextensions. My name here for the file was arbitrary other than I’ll use this for any commands or directive associated with installing additional packages.

Through a little trial and error, I found the latest Zeromq packages for Amazon Linux AMI by enabling the Extra Packages for Enterprise Linux.

The contents of my .ebextensions/packages.config ended up as:

commands:
  01_zmq:
    command: "yum --enablerepo=epel -y install zeromq3"
  02_zmq_dev:
    command: "yum --enablerepo=epel -y install zeromq3-devel"

Then a git add and git commit, and on my next eb deploy the Zeromq packages were installed and the instance was able to complete the npm install including the zmq node bindings.