Reputation: 1406
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 ?
Upvotes: 4
Views: 4019
Reputation: 59
Here is the clear guidance for first time application deployment to elasticbeanstalk.
1) eb init --profile profile-name(profile name will be there in .aws > config)
2) Select default region as you wish to, by entering serial number.
3) Select an application to use, by entering serial number.
4) eb list
5) eb use (name in the list)
6) eb status (will give you the status) That's it you are done with the initialization. And now, if you want to change environment just use following commands.
eb setenv RACK_ENV=staging (takes a while).
eb deploy (after git staging).
You are done!!!!
Upvotes: 1
Reputation: 3752
While I'm using eb_deployer and not the eb
commandline, during an attempt to deploy a RAILS_ENV: development
I found that db:migrate
etc ran in the development environment, but it still started up the server in production mode. To solve this, passing in both RACK_ENV and RAILS_ENV was necessary in the option_settings:
[{
namespace: 'aws:elasticbeanstalk:application:environment',
option_name: 'RACK_ENV',
value: "development"
},
{
namespace: 'aws:elasticbeanstalk:application:environment',
option_name: 'RAILS_ENV',
value: "development"
}]
Upvotes: 1
Reputation: 3280
The --environment
switch in the eb
CLI 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
(or RAILS_ENV
) environment variable inside of your .elasticbeanstalk/optionsettings
file after an eb start
and then call eb update
to 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 the RACK_ENV
field).
Upvotes: 8