【问题标题】:Set environment variable from credstash on Elastic Beanstalk从 Elastic Beanstalk 上的 credstash 设置环境变量
【发布时间】:2019-07-06 01:02:41
【问题描述】:

我想从 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)

我已经指定 credstash 应该从 Python 安装:

packages:
  python:
    credstash: []

但是,当我部署资产时,预编译失败 (rake assets:precompile)。

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_basesecrets.yml 中设置为ENV['SECRET_KEY_BASE'],因此它应该包含来自 credstash 的值。但是,由于credstash: command not found 的输出,我猜测 credstash 没有安装或由于某种原因不在路径上。

有人知道这里会发生什么吗?

【问题讨论】:

    标签: ruby-on-rails amazon-web-services amazon-elastic-beanstalk credstash


    【解决方案1】:

    答案是将RAILS_SKIP_ASSET_COMPILATION 设置为true。这将跳过在安装 credstash 之前运行的 /opt/elasticbeanstalk/hooks/appdeploy/pre/11_asset_compilation.sh 挂钩。

    相反,我将其包含在 .config 文件中:

    container_commands:
      01_assets_compile:
        command: bundle exec rake assets:precompile RAILS_ENV=production
    

    这将在安装 credstash 时预编译每个容器上的资产。

    【讨论】:

      猜你喜欢
      • 2015-06-08
      • 1970-01-01
      • 2015-08-05
      • 2021-04-08
      • 2012-12-21
      • 2020-11-09
      • 2017-07-24
      • 2016-09-08
      • 2020-02-05
      相关资源
      最近更新 更多