Jack is a wrapper tool around the eb cli tool that can be use to manage AWS Elastic Beanstalk environments. It allows you to create environments based on a saved template configuration file, located in the jack/cfg folder of your project. It also provides a helpful config command to manage the template configuration.
For things that this tool does not do, it is recommended that you use use the underlying eb tool directly. This tool has been tested with the 3.3.2 version of the eb command have that version installed.
$ gem install jack-eb
Note that the gem is called jack-eb but the command that is installed is called jack.
This gem relies on a specific version of the eb cli tool. You need the 3.3.2 version of the eb tool. To check the version eb --version
.
cd ~/ && wget https://pypi.python.org/packages/source/a/awsebcli/awsebcli-3.3.2.tar.gz tar -zxvf awsebcli-3.3.2.tar.gz cd awsebcli-3.3.2 sudo python setup.py install
More detail instructions are on AWS EB Documentation, but you do need version 3.3.2 of the awsebcli tool.
You'll also need to set up your environment with your aws access keys since the tool also uses the aws-sdk. Add the following to your ~/.profile, replacing xxx with your actually credentials. Don't forgot to source the ~/.profile or open up a new terminal.
export AWS_ACCESS_KEY_ID=xxx export AWS_SECRET_ACCESS_KEY=xxx
You're ready to go.
In your project folder create a folder call jack/cfg. It might be useful for your company to create a baseline config that you can use. If you do not already have a baseline template, you can download the template from an existing environment like so:
$ jack config download [ENVIRONMENT_NAME]
The path of config that is saved is based on the environment name.
$ jack config download stag-rails-app-s1 Downloading config file... Running: eb config save --cfg current-2015-03-03_18-40-34 stag-rails-app-s1 Configuration saved at: /Users/tung/src/rails/.elasticbeanstalk/saved_configs/current-2015-03-03_18-40-34.cfg.yml Writing to local config file: jack/cfg/stag-rails-app-s1.cfg.yml Cleaning up eb remote config and local files Config downloaded to jack/cfg/stag-rails-app.cfg.yml $
Results in a saved jack/cfg/stag-rails-app-s1.cfg.yml template configuration file. This is overridable.
$ jack config download -c myconfig stag-rails-app-s1
Results in a saved jack/cfg/myconfig.cfg.yml template configuration file.
Configuration templates hold all the options and settings that we can set for an EB environment. Elastic Beanstalk surfaces a portion of all the settings actually available on the underlying AWS Resources that we are allowed to configured. These includes the some of the ELB behavior, VPC, LaunchConfiguration, Autoscaling settings, hard drive size, environment variables, etc.
- Here is an example of all the settings available.
- Here is an example of what you would tyically see when you download the initial saved configuration.
The purpose of the jack/cfg configs is allow us to be able to create environments with a codified configuration file that can be versioned controlled.
$ jack create stag-rails-app-s1 # uses the jack/cfg/stag-rails-app-s1.cfg.yml template $ jack create stag-rails-app-s2 # uses the jack/cfg/stag-rails-app-s2.cfg.yml template $ jack create -c myconfig stag-rails-app-s3 # creates environment using a config not based on environment naming convention
If the project is brand new and has never had eb init
ran on it before. For example, a project that has just been git cloned. Then calling any of the jack commands will automatically call eb init
in the project. eb init
requires the platform flag in order to avoid prompting. By default, the latest Docker solution stack is used for the platform option. But you can override that by creating an ~/.jack/create.yml or jack/create.yml within the project folder. Here's an example. The options from each file is merged using the following precedence: project folder, user home, default that is packaged with this gem. Most of the settings that jack create
should used should be in the template configuration file though.
To download a template configuration.
$ jack config download stag-rails-app-s1
This will save the config to jack/cfg/stag-rails-app-s1.cfg.yml.
To upload a template configuration.
$ jack config upload stag-rails-app-s1
This will save the config to jack/cfg/stag-rails-app-s1.cfg.yml. Here's an example of the output.
Notice that the eb config upload
command also prompts you with the diff before uploading and ask for confirmation. You can bypass the prompt with the force option.
You can use the diff command directly to compare your local config to what configs the environment is actually using is useful. To see the diff.
$ jack config diff stag-rails-app-s1
A note about the configs. They are formatted so that the keys are sorted. This has been done so the diffs are actually useful. It is also recommended you install colordiff so you can see the diff output colorized. You can also specify your own diff viewer via the JACK_DIFF environment variable. Example of colorized diff.
You can get help information from the CLI. Examples:
$ jack help $ jack help create $ jack config help download $ jack config help upload $ jack config help sort
- encrypted the jack/cfg files similar to how shopify/ejson works, except with yaml - pull requests are welcome