Bootstrapping EC2 using User Data Flashcards
What is bootstrapping?
Bootstrapping is a process where scripts or other config steps can be run when an instance is first launched.
What is bootstrapping useful for?
This allows an instance to be brought to service in a particular pre-configured state - including configuration and software installs.
What does bootstrapping allow you to achieve in AWS EC2?
Allows EC2 to build automation.
What does bootstrapping normally uses from EC2 instances?
Bootstrapping is done using user data and it is injected into the instance in the same way that meta-data is.
How can you access bootstrapping user data?
Via the meta-data IP: http://169.254.169.254/latest/user-data
When and by what are the bootstrapping scripts executed?
executed by the instance OS only once on launch time!
Does EC2 run any validation on the user data?
No. You need to be careful with this because the OS needs to understand the data.
Once the bootstrapping scripts (meta-data) are executed, in which states can you find the EC2 instance?
- Running state and ready for service.
- Bad config but still likely running.
- The instance will probably still pass its checks.
- It will not be configured as you expected.
Mention some key points related to User data:
- EC2 doesn’t know what the user data contains, it’s just a block of data.
- The user data is not secure, anyone can see what gets passed in. For this reason it is important not to pass passwords or long term credentials.
- The user data is limited in size - 16 KB
Is the user data limited in some way in size?
- User data is limited to 16 KB in size. Anything larger than this will need to pass a script to download the larger set of data.
What happens if you want to modify the user data? Can you stop the instance, modify the user data and restart the instance to apply the changes?
No, the user data will be executed only at launch.
What is the boot-time-to-service-time?
How quickly after you launch an instance is it ready for service.
What processes are included in the Boot-Time-To-Service-Time?
EC2 to provision the instance and the time required for any software downloads that are needed for the user.
Where can you use AMI baking together with bootstrapping?
To reduce the boot-time-to-service-time, you can configure as much as possible in your backed AMI.
What is post launch time?
manual or automatic configuration done in the instance before the instance is ready for service.
How can bootstrapping influence the post launch time?
Bootstrapping makes possible to launch the instance and then automate the configuration of the instance after it was launched, reducing the post launch time.
What are the trades of using AMI baking for EC2 pre-configuration and SW installations vs bootstrapping?
AMI baking can work in advance, reducing the time needed to get the instance at the desired state.
It also reduces flexibility of configuration.
What is the best way to deal with AMI baking and bootstrapping trades?
Combining them. Do all the time-intensive work before with AMI baking, then do the specifics with bootstrapping.
In this way you have flexibility and reduced post launch time.
Where can you find logs from the bootstrapping executions in EC2 instances?
/var/log/cloud-init-output.log
What do you need to do in advance when using cloudformation to bootstrap an EC2 instance?
You need to encode the user-data in Base64.
It happens automatically using the GUI but in cloudFormation you need to do it manually.