H
H
hoodie2017-11-13 16:47:20
bash
hoodie, 2017-11-13 16:47:20

AWS: How to pass large files (like configs) to USERDATA when creating LaunchConfiguration?

In Amazon AWS, I create a Launch Configuration for an Ubuntu Server 16.04 LTS (HVM) instance, SSD Volume Type - ami-da05a4a0
I then want to use these instances for Auto Scaling Groups
When the instance starts, you need to install nginx, php, nodejs, etc., also you need to install SSL certificates and create custom configs.
To do this, I use the following method in the file that I pass to USERDATA (this is a bash script):

cat << 'EOF' > /etc/nginx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
.... тут весь конфиг ....
EOF

In general, I have several large configs + in the same way I install ssh keys and SSL certificates.
At some point, I came across the error "User data is limited to 16384 bytes" when starting the instance. In this connection, the question arose:
How to transfer configs and install SSL certificates in my case?
I see two options:
1) Create an AMI in which certificates, keys and configs are already saved and in the userdata script, when raising the instance, simply scatter them into the necessary folders. The disadvantage of this approach is that when changing the config, you will need to recreate the AMI image. Though it probably won't happen often.
2) Put all configs, keys and certificates on a separate server, close basic auth and download them with curl or wget when starting the instance.
Please advise how would you do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitri Kaminin, 2017-11-13
@hoodie

you will need to recreate the AMI image. Though it probably won't happen often.

Don't run ahead of the train. If the data will not change often, then do the first option for now, it saves time and is technically simple. If you often change configs, etc., then only do optimization. Look aside packer
The problem with dynamic loading (through the config server) is that when you start the instance, something can go wrong: the Internet is buggy - the config could not be downloaded, your server with configs has crashed, and so on ...
In case you prepare the finished image, then all these problems can be avoided, since everything you need will already be inside. Another plus is that you will have a list of image versions. If something goes wrong, you will always have previous images that you can roll back to.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question