Reputation: 1728
I have an application running on aws elastic beanstalk. The application needs an configuration file, which I putted for testing on the ec2 instance manually.
Problem is, that when the autoscaler decides to scale up to more instances, the application does not have any configuration file on the new instances.
I read about creating templates for the instances. I could put my config file on the instances and then it'll be replicated in the new instance. This has a big disadvantage, 'cause if I wanna change a configuration during runtime, I have to do that on all instances.
Is there an option how I can solve that?
Upvotes: 1
Views: 2248
Reputation: 642
I suggest you put your config file on a safe location like s3 bucket. Keeping sensitive info away from your repository.
Try something like this:
# .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
Upvotes: 0
Reputation: 2415
If we are going deeper:) much better instead of "commands" use "files":
files:
/folder/file.xml:
mode: 000XXX
owner: root
group: users
content: |
<xml>I'm XML</xml>
Upvotes: 0
Reputation: 2666
I agree with Vadim911, DB would be a simpler solution.
But you could use something similar to this to do it when your app is being set up in the environment.
WEB-INF/.ebextensions/commands.config
commands:
replace-file:
command: cp .ebextensions/file.xml /folder/file.xml
Source: infoq
Upvotes: 0
Reputation: 2415
Well, I see two options: 1. When you change config file you need to do environment update on EB. In this case all nodes will be update with new version of config file. 2. Instead of file put your configuration settings to some db, like simpledb or dynamodb. From my point of view this solution is more preferable for your case, if you want to change settings in runtime.
Upvotes: 2