-->

Rails 4.1 AWS Beanstalk cannot find secret key bas

2020-06-23 06:51发布

问题:

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"] %>

回答1:

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

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

  2. Click on the gear button

  3. Enter a new environment variable

    SECRET_KEY_BASE   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    
  4. Save and wait for AWS server to restart