Rails 4.1 AWS Beanstalk cannot find secret key base

amazon-elastic-beanstalk, amazon-web-services, passenger, ruby-2.0, ruby-on-rails-4.1

Solution

I did the following and solved the problem, but it feels kind of forced, like I missed a step somewhere.

Go to elastic beanstalk -> application -> configuration -> software configuration

Click on the gear button

Enter a new environment variable

SECRET_KEY_BASE   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Save and wait for AWS server to restart

Problem

I am trying to upload my rails project on AWS Beanstalk. I've already run eb init, eb start and configured the database settings to point to RDS. After I pushed using git aws.push and waited for AWS server to be started, the link provided says: ``` "502 Bad Gateway nginx" ``` In the logs ``` ------------------------------------- /var/app/support/logs/passenger.log ------------------------------------- App 6861 stderr: [ 2014-05-29 13:26:59.1308 6893/0x00000001e50050(Worker 1) utils.rb:68 ]: *** Exception RuntimeError in Rack application object (Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`) (process 6893, thread 0x00000001e50050(Worker 1)): ``` In my secrets.yml ``` # Do not keep production secrets in the repository, # instead read values from the environment. production: secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> ```

Original source