- Let's talk about bootstrapping
with what we call Userdata in Amazon EC2.
Userdata is ultimately a script that allows an EC2
instance to automatically configure itself
on first boot.
So, this is one of the keys, along with using
multiple availability zones, this is one of the keys
to high availability and what we call
self-healing infrastructures.
I personally don't really like being woken up
at 2:00 in the morning because Apache crashed
or a server failed and I don't really want
to have to get up in the middle of the night
and reinstall and reconfigure software.
Ultimately, I want my environment to automatically
handle that stuff for me.
Bootstrapping with Userdata is one of the ways
that we can do that.
Now, again, this is executed only on the first launch.
What happens is this script on that front boot,
it will be ran and then it will be locked
via a locked file so it doesn't happen if you reboot.
In the case of Linux, if the very first line
of your Userdata is something like #!/bin/bash,
then that will execute that script using the bash
binary executable.
Otherwise, you can use any executable software
that you have installed that is a part
of that Amazon machine image when the instance boots.
You could Node, Python, Go, Ruby, the list goes on.
In the case of Windows, we have the option
of having that be a batch or a powershell script.
If you leave the top line blank,
then Userdata would just be a list of environment variables
that a script that's already a part of the machine image
could then pick up and start using.
So again, bootstrapping with user data
is a really important key to maintaining a highly available
and self-healing environment,
where our EC2 instances can use this script
to configure themselves on first boot.