AWS Elastic Beanstalk配置文件

时间:2013-04-18 13:59:35

标签: configuration amazon-web-services elastic-beanstalk

我在aws弹性beanstalk上运行了一个应用程序。应用程序需要一个配置文件,我把它放在ec2实例上进行手动测试。

问题是,当自动缩放器决定扩展到更多实例时,应用程序在新实例上没有任何配置文件。

我阅读了有关为实例创建模板的信息。我可以将配置文件放在实例上,然后在新实例中复制它。 这有一个很大的缺点,因为如果我想在运行时更改配置,我必须在所有实例上都这样做。

我可以选择如何解决这个问题吗?

4 个答案:

答案 0 :(得分:2)

嗯,我看到两个选择: 1.更改配置文件时,需要在EB上进行环境更新。在这种情况下,所有节点都将使用新版本的配置文件进行更新。 2.而不是文件将您的配置设置放到某个数据库,如simpledb或dynamodb。从我的角度来看,如果你想在运行时改变设置,这个解决方案对你的情况更为可取。

答案 1 :(得分:0)

我同意Vadim911,DB将是一个更简单的解决方案。

但是,当您在环境中设置应用时,您可以使用与此相似的内容。

WEB-INF / .ebextensions / commands.config

commands:
  replace-file:
    command: cp .ebextensions/file.xml /folder/file.xml

来源:infoq

答案 2 :(得分:0)

如果我们要更深入:)更好而不是“命令”使用“文件”:

files:
    /folder/file.xml:
        mode: 000XXX
        owner: root
        group: users
        content: |
           <xml>I'm XML</xml>

答案 3 :(得分:0)

我建议你将配置文件放在像s3存储桶这样的安全位置。保持敏感信息远离您的存储库。

尝试这样的事情:

# .ebexetensions/safe-config-install.config

files:
  "/tmp/cron-fetch-config.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      for f in /etc/profile.d/*.sh; do source $f; done;

      python -c "import boto;boto.connect_s3().get_bucket('my-private-bucket').get_key('secretfolder/secretfile.xml').get_contents_to_filename('/var/app/current/path/to/config.xml');

container_commands:
  install-config:
    command: python -c "import boto;boto.connect_s3().get_bucket('my-private-bucket').get_key('secretfolder/secretfile.xml').get_contents_to_filename('/var/app/ondeck/path/to/config.xml');

commands:
  setup-cron-for-config:
    command: echo -e "* * * * * root /tmp/cron-fetch-config.sh\n" > /etc/cron.d/my_cron
相关问题