[英]Set environment variable from credstash on Elastic Beanstalk
I'm having some issues with Elastic Beanstalk environment variables which I want to set from credstash. 我要从credstash设置的Elastic Beanstalk环境变量存在一些问题。
option_settings:
- namespace: aws:elasticbeanstalk:application:environment
option_name: SECRET_KEY_BASE
value: $(credstash --region eu-west-1 -t credstash get test.secret_key_base)
I have specified that credstash should be installed from Python: 我指定应从Python安装credstash:
packages:
python:
credstash: []
However, when I deploy asset precompilation fails ( rake assets:precompile
). 但是,当我部署资产时,预编译失败(
rake assets:precompile
)。
The EB health page shows that application deployment failed. EB运行状况页面显示应用程序部署失败。
/opt/elasticbeanstalk/support/envvars: line 5: credstash: command not found
...
+ su -s /bin/bash -c 'bundle exec rake assets:precompile' webapp
`/home/webapp` is not a directory.
Bundler will use `/tmp/bundler/home/webapp' as your home directory temporarily.
rake aborted!
ArgumentError: `secret_key_base` for production environment must be a type of String`
secret_key_base
is set to ENV['SECRET_KEY_BASE']
in secrets.yml
, so it should contain the value from credstash. secret_key_base
设为ENV['SECRET_KEY_BASE']
中secrets.yml
,因此它应该含有credstash值。 However, due to the credstash: command not found
output, I'm guessing credstash was not installed or is not on the path for some reason. 但是,由于
credstash: command not found
输出,我猜测credstash未安装或由于某种原因不在路径上。
Does anyone have any idea what could be going on here? 有谁知道这里会发生什么?
The answer was to set RAILS_SKIP_ASSET_COMPILATION
to true
. 答案是将
RAILS_SKIP_ASSET_COMPILATION
设置为true
。 This will skip the /opt/elasticbeanstalk/hooks/appdeploy/pre/11_asset_compilation.sh
hook, which runs before credstash is installed. 这将跳过
/opt/elasticbeanstalk/hooks/appdeploy/pre/11_asset_compilation.sh
钩子,该钩子在安装credstash之前运行。
Instead I included this in a .config
file: 相反,我将此包含在
.config
文件中:
container_commands:
01_assets_compile:
command: bundle exec rake assets:precompile RAILS_ENV=production
This will precompile the assets on each container, when credstash will be installed. 安装credstash时,这将在每个容器上预编译资产。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.