nemo
nemo

Reputation: 485

Deploying Rails App to Elastic Beanstalk using EB CLI 3.0X

I am trying to redeploy a RoR app using EB CLI 3.0x

I have been previously successful in deploying my app using EB CLI 2 on Amazon Linux stack 2014.03 with Ruby Puma 2.0. However deploying the app with CLI 3.0 on Amazon Linux 2014.09 with Puma 2.0 is giving me errors.

The first issue was with renaming postgresql-dev to postgresql92-dev or postgresql93-dev which has been quite common for everyone. But further to this, I am facing the following issues:

The deployment environment doesn't seem to run bundle install and db migrate / seed etc.

More importantly the environment variables are missing from the instance. In my deployment with EB CLI 2 and Amazon Linux 2014.03, I could write my .ebextension configurations and use environment variables in /opt/elasticbeanstalk/containerfiles/envvars. The older deployment would initialize variables like $EB_CONFIG_APP_PIDS and $EB_CONFIG_APP_CURRENT that I could use in my config files.

The new version however gives me a rather empty envvars file under /opt/elasticbeanstalk/support/envvars and none of the previous environment variables are present. Also I had to manually configure my database and connect it to my application.

I wonder if anyone else has encountered similar problems and whether there is any solution for an easy migration from an older version of Elastic Beanstalk CLI to the newer version.

It would also be great if someone could point me to a newer version of the .ebextensions written to auto-start sidekiq / cron services etc.

Upvotes: 3

Views: 993

Answers (1)

Ruggero
Ruggero

Reputation: 41

Even if it's an old thread:

AWS changed the way to get this variables, e.g.:

EB_APP_STAGING_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir)

A complete list of CONTAINER variables can be obtained with:

/opt/elasticbeanstalk/bin/get-config container --output=yaml
---
app_staging_dir: "/var/app/ondeck"
instance_port: '80'
gem_dir: "/opt/elasticbeanstalk/support/gems/puma"
http_port: '80'
app_deploy_dir: "/var/app/current"
node_install_dir: "/opt/elasticbeanstalk/support/node-install"
puma_version: 2.9.1
node_version: 0.10.33
app_log_dir: "/var/app/containerfiles/logs"
ruby_version: 2.1.5
script_dir: "/opt/elasticbeanstalk/support/scripts"
source_bundle: "/opt/elasticbeanstalk/deploy/appsource/source_bundle"
app_pid_dir: "/var/app/containerfiles/pids"
puma_pid_dir: "/var/run/puma"
app_asset_dir: "/var/app/containerfiles/assets"
tarball_url: https://s3-eu-west-1.amazonaws.com/elasticbeanstalk-env-resources-eu-west-1/stalks/eb_ruby_puma_3.11.1/lib/tarballs
puma_log_dir: "/var/log/puma"
app_user: webapp
support_dir: "/opt/elasticbeanstalk/support"

Other configuration categories and options can be obtained running

/opt/elasticbeanstalk/bin/get-config -h
Usage: get-config CATEGORY [OPTIONS]

Categories:
    optionsettings                   environment option settings that affect instance
    container                        container specific configurations
    addons                           addon configurations
    environment                      environment variables
    meta                             EB environment meta-data

Options:
    -k, --key KEY                    Key of specific configurations.
        --output OUTPUT_FORMAT       Output format. Can be JSON or YAML. Default is JSON.
    -n, --namespace NAMESPACE        Otion Setting namespace for retrieval. Only applied to Category optionsettings.
    -o, --option-name OPTION_NAME    Option Setting name for retrieval. Only applied to Category optionsettings.
    -a, --add-on ADDON               Add-on name. Only applied to Category addons.
    -h, --help                       Help

Hope this helps people upgrading their stacks to 2014.09 and subsequent.

Upvotes: 4

Related Questions