I'm new to aws. Instance is running on ruby 3.0, AL2 with rails v 7.0.2.4. I am having problem to get the environment variable that I have configured in elastic beanstalk from the aws ec2 instance session manager console. I want to run a cronjob, and the cronjob is having a problem to initialize due to missing env variable.
The cronjob log throws this error when starting up, due to missing secret key base.
/var/app/current/vendor/bundle/ruby/3.0.0/gems/railties-7.0.2.4/lib/rails/application.rb:580:in `validate_secret_key_base': Missing `secret_key_base`
The secret_key_base is fetched from config/secrets.yml file. The content is roughly like
test:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
It gets the secret key base from elastic beanstalk env variable, and I check the configuration in aws. All good.
I tried calling the variable manually using echo $ENV["SECRET_KEY_BASE"] in session manager console, but didn't work.
But all of the environment variable can be accessed using aws get-config, like $(/opt/elasticbeanstalk/bin/get-config environment) and all the environment variable will be shown in JSON.
But I don't know how to assign the values from get-config to their respective variables, mainly ENV["SECRET_KEY_BASE"].