1 00:00:06,682 --> 00:00:08,202 - Let's talk about bootstrapping 2 00:00:08,202 --> 00:00:11,619 with what we call Userdata in Amazon EC2. 3 00:00:14,135 --> 00:00:18,302 Userdata is ultimately a script that allows an EC2 4 00:00:19,632 --> 00:00:23,006 instance to automatically configure itself 5 00:00:23,006 --> 00:00:24,173 on first boot. 6 00:00:25,699 --> 00:00:29,449 So, this is one of the keys, along with using 7 00:00:30,981 --> 00:00:34,231 multiple availability zones, this is one of the keys 8 00:00:34,231 --> 00:00:36,900 to high availability and what we call 9 00:00:36,900 --> 00:00:39,243 self-healing infrastructures. 10 00:00:39,243 --> 00:00:42,317 I personally don't really like being woken up 11 00:00:42,317 --> 00:00:45,674 at 2:00 in the morning because Apache crashed 12 00:00:45,674 --> 00:00:49,184 or a server failed and I don't really want 13 00:00:49,184 --> 00:00:50,725 to have to get up in the middle of the night 14 00:00:50,725 --> 00:00:53,837 and reinstall and reconfigure software. 15 00:00:53,837 --> 00:00:58,587 Ultimately, I want my environment to automatically 16 00:00:58,587 --> 00:01:00,741 handle that stuff for me. 17 00:01:00,741 --> 00:01:03,565 Bootstrapping with Userdata is one of the ways 18 00:01:03,565 --> 00:01:05,344 that we can do that. 19 00:01:05,344 --> 00:01:09,511 Now, again, this is executed only on the first launch. 20 00:01:11,169 --> 00:01:14,024 What happens is this script on that front boot, 21 00:01:14,024 --> 00:01:16,918 it will be ran and then it will be locked 22 00:01:16,918 --> 00:01:20,317 via a locked file so it doesn't happen if you reboot. 23 00:01:20,317 --> 00:01:23,618 In the case of Linux, if the very first line 24 00:01:23,618 --> 00:01:27,785 of your Userdata is something like #!/bin/bash, 25 00:01:31,116 --> 00:01:33,592 then that will execute that script using the bash 26 00:01:33,592 --> 00:01:35,092 binary executable. 27 00:01:35,938 --> 00:01:39,931 Otherwise, you can use any executable software 28 00:01:39,931 --> 00:01:43,908 that you have installed that is a part 29 00:01:43,908 --> 00:01:47,707 of that Amazon machine image when the instance boots. 30 00:01:47,707 --> 00:01:51,874 You could Node, Python, Go, Ruby, the list goes on. 31 00:01:53,134 --> 00:01:55,725 In the case of Windows, we have the option 32 00:01:55,725 --> 00:01:59,972 of having that be a batch or a powershell script. 33 00:01:59,972 --> 00:02:02,639 If you leave the top line blank, 34 00:02:03,778 --> 00:02:07,244 then Userdata would just be a list of environment variables 35 00:02:07,244 --> 00:02:11,503 that a script that's already a part of the machine image 36 00:02:11,503 --> 00:02:13,996 could then pick up and start using. 37 00:02:13,996 --> 00:02:15,899 So again, bootstrapping with user data 38 00:02:15,899 --> 00:02:20,066 is a really important key to maintaining a highly available 39 00:02:21,234 --> 00:02:23,400 and self-healing environment, 40 00:02:23,400 --> 00:02:27,458 where our EC2 instances can use this script 41 00:02:27,458 --> 00:02:30,625 to configure themselves on first boot.