- Now let's review bootstrapping with Userdata.
Within EC2 Userdata,
are scripts that would allow
an instance to configure itself.
So remember that earlier we talked about how
with the on-demand nature of EC2,
we can launch a machine at any time.
And when that machine comes to life,
we need that machine to perhaps start certain processes,
perhaps download different pieces of code,
or call home to a configuration management service.
But so the Userdata allows us to do that.
It is one of the keys to high-availability
and self-healing, right?
When we think about an environment in which
due to the disposable nature of EC2 instances,
they really can come and go at anytime,
and so as we'll talk about later,
when we get into Auto Scaling,
you can imagine that if we were to create a system
where with very little manual intervention,
and we have a machine come to life,
we need a way for this machine to configure itself.
And in doing so and creating that kind of thing
with Auto Scaling and automatic bootstrapping,
we can create self-healing environments.
It's a very, very powerful pattern
for enabling fault tolerance and high-availability
and efficiency in our processes.
And so, the Userdata that we have,
we do have a limit of 16 K.
And these scripts are executed on the first boot,
at launch on the first boot.
And so if we were to reboot that machine,
no matter how many times,
that script would never be executed a second time.
It's only executed during the first boot, right?
Now it doesn't have to be a script,
it can be a list of environment variables as well.
So, for different operating systems,
while in Linux we have the ability
to create simple bash scripts,
or it could be Node.js, or Python,
or pretty much any executable binary
that we can list, right?
And in basically any other executable.
For Windows, we can use a batch script,
or a powershell script.
So either way, we have this really powerful ability
to give our EC2 instance enough information
to get itself up and running,
doing what it's supposed to do,
without manual intervention.
And so when we combine Userdata with
the Instance Metadata Service,
with custom private Amazon machine images,
that gives us a very powerful tool
for creating a very efficient, automated, self-healing,
and fault-tolerant environment.