In this video, Jeff Winesett covers the topic of bootstrapping. Bootstrapping is setting up a repeatable process from which additional AWS resources can be created. Bootstrapping is key to leveraging scaling in the cloud.
- [Instructor] Bootstrapping is an important concept to understand for taking advantage of the cloud's elastic nature, which is going to drive some of the biggest benefits realized from a cloud-based environment versus a traditional one. Bootstrapping refers to creating a sustainable, start up process that can run on its own and in the context of AWS it typically means the process needed to get an application up and running on an EC2 instance. Application instances should be able to come online and then ask questions about who they are and what role they're supposed to be playing in the application.
Am I an app server? Am I a database server? Then, based on understanding what role its playing an instance should be able to retrieve needed resources such as code files, configuration information and utility scripts then register itself as a component in the system. The actions involved during a bootstrap phase can be anything and should be everything needed to have an instance be ready to play its role in the application.
An example bootstrap process could be as follows: mount the needed drives, start any of the needed services, update files, or pull down needed scripts, get the latest version of supporting software, and apply any needed software patches and then, perhaps, register itself with a load balancer to begin receiving traffic. The tools needed to achieve this bootstrapping depends on the application environment and specific application requirements.
Some examples are running custom scripts on the servers. When an instance starts up, custom scripts can run to set configuration settings, start services and apply software updates. To aid in this effort, AWS offers a few tools to help run custom scripts as part of a bootstrapping process. One of the tools AWS offers is access to the instance metadata. This data can be accessed from within the instance, directly from the command line.
So, let me take just a moment to demonstrate this. Here, I have launched an EC2 instance and I am accessing the command line on the instance via SSH. Don't worry how I got here at this point. I'll be demonstrating launching and accessing EC2 instances later in this course. Right now, I just want to show this instance metadata. All EC2 instance data is available at the same end point over HTTP. On a Linux instance, you can use something like the curl command to get the data.
I'll use curl and list out available metadata options. I can do so right here from the command line. Just type in: curl http :// 169 .254 .169 .254, followed by the word latest and then followed by the word meta-data. Running this command returns a listing of all the instance meta-data that's available on this instance.
It's quite a long list, so, I'll look at just a couple. For example, say I want to get the instance's host name. That is the IPv4 DNS Host Name of the instance. I can use the same URL end point and just type in hostname at the end. So, using the same URL I used before, I use the command, hostname, and we see this command out of the listing too and just to add some readability to the output I'm going to just echo out a new line so that we can read that better, off the command line.
There it is, that's the IPv4 DNS host name of this instance. I could also take a look at, for example, the unique AMI id from which this instance was created. I use the same end point again but this time, I'll use the ami-id from the listing above. So, I'll type in ami id and, again, I'll echo out a new line for readability.
And there it is. That's the unique AMI id of this instance. And then, for example, I could also look at the unique instance identifier that this instance has associated with it. To see that, I just type in instance, dash, id. So, again, I'll back up, here and I'll use the command instance id and again, there it is. All of this data is accessible by simply accessing this same end point from anywhere on the instance.
These values can also be accessed from within scripts that run on the instances. This data can help with a bootstrap process. Another tool to help with bootstrapping, offered by AWS, is something called Cloud-init for Linux servers or EC2Config for Windows servers. These allow custom scripts or any shell commands to be specified and run during the instance start up process. This makes it easy to specify server bootstrap needs and they will automatically be run at the appropriate time during the overall instance start up life-cycle.
Later in this course, I will demonstrate using Cloud-init to script the setup of a new server and demonstrate the use of user data and Cloud-init to bootstrap a new instance. While writing and maintaining custom scripts for instance bootstrapping can work well for simple applications, there are other configuration management tools and services available that can come in quite handy when systems grow in complexity. Elastic Beanstalk, OpsWorks, CloudFormation and CodeDeploy are some examples.
Implementing elasticity lesson number one: take the time to write the scripts or configure management tools necessary to bootstrap instances. Automating this process will allow you to take advantage of the cloud's elastic nature.
- Benefits of cloud services
- Making architectures scalable
- Examining cloud constraints
- Virtual servers, EC2, and Elastic IP
- Using the Amazon machine image
- Elastic load balancing
- Using CloudWatch for monitoring
- Security Models
- Elastic block storage
- S3, CloudFront, and Elastic Beanstalk
- Handling queues, workflows, and notifications
- Caching options and services
- Identity and access management
- Creating a custom server image
- Application deployment strategies
- Serverless architectures