I am trying to bring up a staging instance of rails applciation using elastic beanstalk. I followed the documentation and did the following :
eb init --environment staging
eb start --environment staging
After this, I checked that the .elasticbeanstalk/optionsettings still had ‘production’ as the environment. I manually updated this to staging, and tried the git aws.push command.
After sometime, everything was deployed, However, when I load the URL, the application still seems to be using all the production configs and not the staging. Am I missing any step ?
The
--environmentswitch in theebCLI tool does not refer to the Rails environment, it refers to the Elastic Beanstalk environment which you are attempting to launch. The Elastic Beanstalk environment is a set of provisioned resources for a deployed application version. This is different from a Rails/Rack environment, which is simply a user defined context for application code to run in on an individual machine.In order to set your Rails environment, you will want to set the
RACK_ENV(orRAILS_ENV) environment variable inside of your.elasticbeanstalk/optionsettingsfile after aneb startand then calleb updateto trigger an update of these environment variables. Or, you can edit your Elastic Beanstalk environment configuration through the Elastic Beanstalk console; click on “Environment details” on the correct environment, “Edit Configuration” in the Overview, and go to “Container” to adjust environment variables (in this case, you will edit theRACK_ENVfield).