Configuration AWS弹性豆茎配置文件
我有一个在aws elastic beanstalk上运行的应用程序。应用程序需要一个配置文件,我将其放在ec2实例上手动测试 问题是,当autoscaler决定扩展到更多实例时,应用程序在新实例上没有任何配置文件 我阅读了有关为实例创建模板的内容。我可以将配置文件放在实例上,然后将其复制到新实例中。 这有一个很大的缺点,因为如果我想在运行时更改配置,我必须在所有实例上都这样做 有什么办法可以解决这个问题吗?我有两个办法: 1.当您更改配置文件时,需要在EB上执行环境更新。在这种情况下,所有节点都将更新为新版本的配置文件。Configuration AWS弹性豆茎配置文件,configuration,amazon-web-services,amazon-elastic-beanstalk,Configuration,Amazon Web Services,Amazon Elastic Beanstalk,我有一个在aws elastic beanstalk上运行的应用程序。应用程序需要一个配置文件,我将其放在ec2实例上手动测试 问题是,当autoscaler决定扩展到更多实例时,应用程序在新实例上没有任何配置文件 我阅读了有关为实例创建模板的内容。我可以将配置文件放在实例上,然后将其复制到新实例中。 这有一个很大的缺点,因为如果我想在运行时更改配置,我必须在所有实例上都这样做 有什么办法可以解决这个问题吗?我有两个办法: 1.当您更改配置文件时,需要在EB上执行环境更新。在这种情况下,所有节点
2.将配置设置放在一些数据库中,如simpledb或dynamodb,而不是文件。从我的观点来看,如果您想在运行时更改设置,此解决方案更适合您的情况。我同意Vadim911,DB将是一个更简单的解决方案 但是,当您的应用程序在环境中设置时,您可以使用类似的方法来完成此操作 WEB-INF/.ebextensions/commands.config
commands:
replace-file:
command: cp .ebextensions/file.xml /folder/file.xml
来源:如果我们更深入:)更好地使用“文件”而不是“命令”:
文件:
/folder/file.xml:
模式:000XXX
所有者:root
组:用户
内容:|
我是XML
我建议您将配置文件放在像s3 bucket这样的安全位置。将敏感信息远离存储库
试着这样做:
# .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
谢谢,这就是我一直在寻找的解决方案。唯一的缺点是速度取决于服务器必须处理的请求数量。我使用cacheserver修复了这个问题,并每10分钟更新一次cacheserver。
# .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