Sitting on a plane on a business trip, got a few minutes to spare so I figured I’d add a little tip I learned…
Over at Hifi we use Amazon’s Elastic Beanstalk to power one of our internal APIs. The idea here is that you expose a WSGI-enabled file that Amazon will allocate hardware for, spin up machines, serve, scale, handle DNS routing, etc. It’s some kind of magic (it’s not really that magical, but it is nice).
When setting up these machines, the general idea is that you specify a few parameters, like what kind of machines to use, what circumstances it should spin up and down machines for, but then these things should be basically hands off, running a pretty vanilla version of your code, and that you should never have to actually SSH into the boxes.
But sometimes you do have to SSH into the boxes! Sometimes you want to debug something, or add additional logging right on a machine, or something like that, but when you ssh in, those babies are pretty uninviting. Here’s where a little customization goes a long way (or not). Why not give that login prompt some nice PS1 coloring?!
As far as customizing your Elastic Beanstalk boxes:
- Create a directory in your project called
.ebextensionsthat has one or more config files with information about specifically how/what to customize. There’s a bunch of documentation about possible customizations. If you don’t already have a config file, create one in this directory (something like
- Modify that config by adding the following in the files section, creating it if it doesn’t exist:
A few notes:
- The default user when you login to an Elastic Beanstalk box is
- Feel free to use whatever PS1 you like, the one I chose is the “Pink and Blue” theme from kirsle.net/wizards/ps1.html
- Note the filename is
/opt/elasticbeanstalk/hooks/appdeploy/post/997_setup_ps1.sh– this directory contains executable files that will be executed post-deployment. The
997is just a high number, so it’s one of the last files in there that gets run. Do what suits you.
- I’m sure this could be done a few other ways, this is just the one I went with.