1 00:00:06,790 --> 00:00:10,160 - Now let's review bootstrapping with Userdata. 2 00:00:10,160 --> 00:00:13,560 Within EC2 Userdata, 3 00:00:13,560 --> 00:00:16,560 are scripts that would allow 4 00:00:16,560 --> 00:00:19,860 an instance to configure itself. 5 00:00:19,860 --> 00:00:22,860 So remember that earlier we talked about how 6 00:00:22,860 --> 00:00:25,330 with the on-demand nature of EC2, 7 00:00:25,330 --> 00:00:27,650 we can launch a machine at any time. 8 00:00:27,650 --> 00:00:30,067 And when that machine comes to life, 9 00:00:30,067 --> 00:00:34,711 we need that machine to perhaps start certain processes, 10 00:00:34,711 --> 00:00:38,300 perhaps download different pieces of code, 11 00:00:38,300 --> 00:00:41,870 or call home to a configuration management service. 12 00:00:41,870 --> 00:00:45,023 But so the Userdata allows us to do that. 13 00:00:46,210 --> 00:00:49,060 It is one of the keys to high-availability 14 00:00:49,060 --> 00:00:50,990 and self-healing, right? 15 00:00:50,990 --> 00:00:52,879 When we think about an environment in which 16 00:00:52,879 --> 00:00:56,800 due to the disposable nature of EC2 instances, 17 00:00:56,800 --> 00:00:59,200 they really can come and go at anytime, 18 00:00:59,200 --> 00:01:01,349 and so as we'll talk about later, 19 00:01:01,349 --> 00:01:03,510 when we get into Auto Scaling, 20 00:01:03,510 --> 00:01:07,709 you can imagine that if we were to create a system 21 00:01:07,709 --> 00:01:12,020 where with very little manual intervention, 22 00:01:12,020 --> 00:01:13,571 and we have a machine come to life, 23 00:01:13,571 --> 00:01:18,440 we need a way for this machine to configure itself. 24 00:01:18,440 --> 00:01:20,470 And in doing so and creating that kind of thing 25 00:01:20,470 --> 00:01:23,340 with Auto Scaling and automatic bootstrapping, 26 00:01:23,340 --> 00:01:26,130 we can create self-healing environments. 27 00:01:26,130 --> 00:01:27,920 It's a very, very powerful pattern 28 00:01:27,920 --> 00:01:31,833 for enabling fault tolerance and high-availability 29 00:01:31,833 --> 00:01:36,140 and efficiency in our processes. 30 00:01:36,140 --> 00:01:40,040 And so, the Userdata that we have, 31 00:01:40,040 --> 00:01:42,593 we do have a limit of 16 K. 32 00:01:43,560 --> 00:01:47,520 And these scripts are executed on the first boot, 33 00:01:47,520 --> 00:01:49,310 at launch on the first boot. 34 00:01:49,310 --> 00:01:51,535 And so if we were to reboot that machine, 35 00:01:51,535 --> 00:01:53,135 no matter how many times, 36 00:01:53,135 --> 00:01:57,200 that script would never be executed a second time. 37 00:01:57,200 --> 00:02:01,800 It's only executed during the first boot, right? 38 00:02:01,800 --> 00:02:03,710 Now it doesn't have to be a script, 39 00:02:03,710 --> 00:02:06,793 it can be a list of environment variables as well. 40 00:02:07,890 --> 00:02:09,907 So, for different operating systems, 41 00:02:09,907 --> 00:02:12,820 while in Linux we have the ability 42 00:02:12,820 --> 00:02:16,090 to create simple bash scripts, 43 00:02:16,090 --> 00:02:19,560 or it could be Node.js, or Python, 44 00:02:19,560 --> 00:02:22,738 or pretty much any executable binary 45 00:02:22,738 --> 00:02:25,193 that we can list, right? 46 00:02:27,448 --> 00:02:29,583 And in basically any other executable. 47 00:02:29,583 --> 00:02:34,380 For Windows, we can use a batch script, 48 00:02:34,380 --> 00:02:36,380 or a powershell script. 49 00:02:36,380 --> 00:02:39,600 So either way, we have this really powerful ability 50 00:02:39,600 --> 00:02:44,290 to give our EC2 instance enough information 51 00:02:44,290 --> 00:02:46,093 to get itself up and running, 52 00:02:46,093 --> 00:02:48,210 doing what it's supposed to do, 53 00:02:48,210 --> 00:02:50,410 without manual intervention. 54 00:02:50,410 --> 00:02:54,610 And so when we combine Userdata with 55 00:02:54,610 --> 00:02:56,520 the Instance Metadata Service, 56 00:02:56,520 --> 00:03:00,500 with custom private Amazon machine images, 57 00:03:00,500 --> 00:03:02,700 that gives us a very powerful tool 58 00:03:02,700 --> 00:03:07,390 for creating a very efficient, automated, self-healing, 59 00:03:07,390 --> 00:03:09,163 and fault-tolerant environment.