• <legend id='NG5gX'><style id='NG5gX'><dir id='NG5gX'><q id='NG5gX'></q></dir></style></legend>

    1. <i id='NG5gX'><tr id='NG5gX'><dt id='NG5gX'><q id='NG5gX'><span id='NG5gX'><b id='NG5gX'><form id='NG5gX'><ins id='NG5gX'></ins><ul id='NG5gX'></ul><sub id='NG5gX'></sub></form><legend id='NG5gX'></legend><bdo id='NG5gX'><pre id='NG5gX'><center id='NG5gX'></center></pre></bdo></b><th id='NG5gX'></th></span></q></dt></tr></i><div id='NG5gX'><tfoot id='NG5gX'></tfoot><dl id='NG5gX'><fieldset id='NG5gX'></fieldset></dl></div>

        <small id='NG5gX'></small><noframes id='NG5gX'>

          <bdo id='NG5gX'></bdo><ul id='NG5gX'></ul>
        <tfoot id='NG5gX'></tfoot>

        如何在 Amazon Elastic Beanstalk (Python) 中设置环境变量

        时间:2023-07-04

        <small id='zdaMI'></small><noframes id='zdaMI'>

              <bdo id='zdaMI'></bdo><ul id='zdaMI'></ul>
              <tfoot id='zdaMI'></tfoot>

                  <tbody id='zdaMI'></tbody>
                <legend id='zdaMI'><style id='zdaMI'><dir id='zdaMI'><q id='zdaMI'></q></dir></style></legend>
                <i id='zdaMI'><tr id='zdaMI'><dt id='zdaMI'><q id='zdaMI'><span id='zdaMI'><b id='zdaMI'><form id='zdaMI'><ins id='zdaMI'></ins><ul id='zdaMI'></ul><sub id='zdaMI'></sub></form><legend id='zdaMI'></legend><bdo id='zdaMI'><pre id='zdaMI'><center id='zdaMI'></center></pre></bdo></b><th id='zdaMI'></th></span></q></dt></tr></i><div id='zdaMI'><tfoot id='zdaMI'></tfoot><dl id='zdaMI'><fieldset id='zdaMI'></fieldset></dl></div>

                  本文介绍了如何在 Amazon Elastic Beanstalk (Python) 中设置环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我最近一直在开发一个 Django 应用程序,试图让它与 Amazon Elastic Beanstalk 一起工作.

                  I have been working on a Django application lately, trying to get it to work with Amazon Elastic Beanstalk.

                  在我的 .ebextensions/python.config 文件中,我设置了以下内容:

                  In my .ebextensions/python.config file, I have set the following:

                  option_settings:
                    - namespace: aws:elasticbeanstalk:application:environment
                      option_name:  ProductionBucket
                      value: s3-bucket-name
                    - namespace: aws:elasticbeanstalk:application:environment
                      option_name:  ProductionCache
                      value:  memcached-server.site.com:11211
                  

                  但是,每当我查看服务器时,都没有设置此类环境变量(因此,当我尝试 os.getenv('ProductionBucket')

                  However, whenever I look on the server, no such environment variables are set (and as such, aren't accessible when I try os.getenv('ProductionBucket')

                  我遇到了这个 this page,它似乎试图记录所有命名空间.我也尝试使用 PARAM1 作为选项名称,但结果相似.

                  I came across this this page which appears to attempt to document all the namespaces. I've also tried using PARAM1 as the option name, but have had similar results.

                  如何在 Amazon Elastic Beanstalk 中设置环境变量?

                  How can I set environment variables in Amazon Elastic Beanstalk?

                  编辑:
                  我还尝试在所有其他仅导出环境变量的命令之前添加一个命令:

                  EDIT:
                  I have also tried adding a command prior to all other commands which would just export an environment variable:

                  commands:
                   01_env_vars:
                    command: "source scripts/env_vars"
                  

                  ...这也失败了

                  推荐答案

                  我检查了使用现代(即非遗留)容器,并在/opt/elasticbeanstalk/deploy/configuration/containerconfiguration 下找到它作为 json 文件.

                  I've checked using a modern (i.e., non legacy) container, and found it under /opt/elasticbeanstalk/deploy/configuration/containerconfiguration as a json file.

                  行为似乎是平台相关的:我记得特别是在 PHP 中,它还创建了一些带有值的 shell 脚本.

                  The Behaviour seems to be Platform-Dependent: I remember in PHP in particular, it also creates some shell scripts with the values.

                  无论如何,请查看/opt/elasticbeanstalk/hooks/configdeploy.

                  Regardless of that, look into /opt/elasticbeanstalk/hooks/configdeploy.

                  Java 案例,它运行这个 python 脚本,对你来说看起来很方便:

                  Java case again, it runs this python script, which looks quite handy for you:

                  https://gist.github.com/19c1e4b718f9a70a4ce1

                  这篇关于如何在 Amazon Elastic Beanstalk (Python) 中设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:python - os.getenv 和 os.environ 看不到我的 bash shell 的环境变量 下一篇:cron运行python脚本时的环境变量

                  相关文章

                  <i id='5vSbm'><tr id='5vSbm'><dt id='5vSbm'><q id='5vSbm'><span id='5vSbm'><b id='5vSbm'><form id='5vSbm'><ins id='5vSbm'></ins><ul id='5vSbm'></ul><sub id='5vSbm'></sub></form><legend id='5vSbm'></legend><bdo id='5vSbm'><pre id='5vSbm'><center id='5vSbm'></center></pre></bdo></b><th id='5vSbm'></th></span></q></dt></tr></i><div id='5vSbm'><tfoot id='5vSbm'></tfoot><dl id='5vSbm'><fieldset id='5vSbm'></fieldset></dl></div>
                    <bdo id='5vSbm'></bdo><ul id='5vSbm'></ul>

                  <tfoot id='5vSbm'></tfoot>
                1. <small id='5vSbm'></small><noframes id='5vSbm'>

                    1. <legend id='5vSbm'><style id='5vSbm'><dir id='5vSbm'><q id='5vSbm'></q></dir></style></legend>