1 00:00:00,300 --> 00:00:01,440 ‫Okay, so let's go ahead 2 00:00:01,440 --> 00:00:04,500 ‫and practice using the Beanstalk service. 3 00:00:04,500 --> 00:00:07,470 ‫So I'm gonna go into the Elastic Beanstalk console, 4 00:00:07,470 --> 00:00:10,680 ‫and we're going to create our first application. 5 00:00:10,680 --> 00:00:12,480 ‫So we have an option to choose 6 00:00:12,480 --> 00:00:16,440 ‫either a web server environment or a worker environment. 7 00:00:16,440 --> 00:00:17,940 ‫So right now, we want to run a website 8 00:00:17,940 --> 00:00:19,860 ‫so we'll choose web server environment, 9 00:00:19,860 --> 00:00:22,800 ‫but if you wanted to process tasks off of a queue, 10 00:00:22,800 --> 00:00:25,230 ‫then we would choose a worker environment 11 00:00:25,230 --> 00:00:27,330 ‫but we will only do web server. 12 00:00:27,330 --> 00:00:29,250 ‫So let's create an application, 13 00:00:29,250 --> 00:00:32,090 ‫and this one is called MyApplication, okay. 14 00:00:33,480 --> 00:00:37,230 ‫So next, we scroll down and we have environment information. 15 00:00:37,230 --> 00:00:38,970 ‫So the environment is auto-filled, 16 00:00:38,970 --> 00:00:42,750 ‫but I'm just going to call this one MyApplication-dev 17 00:00:42,750 --> 00:00:44,190 ‫because this is going to represent 18 00:00:44,190 --> 00:00:46,200 ‫my development environment. 19 00:00:46,200 --> 00:00:48,960 ‫The domain name is going to be automatically generated 20 00:00:48,960 --> 00:00:49,980 ‫for my application, 21 00:00:49,980 --> 00:00:52,950 ‫and this is how I will access my web servers. 22 00:00:52,950 --> 00:00:54,480 ‫Okay, so we scroll down 23 00:00:54,480 --> 00:00:56,610 ‫and now we need to choose a platform. 24 00:00:56,610 --> 00:00:58,950 ‫So this platform is going to be managed 25 00:00:58,950 --> 00:01:01,440 ‫and I will choose Node.js, 26 00:01:01,440 --> 00:01:03,150 ‫and then I will just choose the default options. 27 00:01:03,150 --> 00:01:04,770 ‫You may see something different than me 28 00:01:04,770 --> 00:01:07,110 ‫but by using the latest default, 29 00:01:07,110 --> 00:01:09,330 ‫you should be fine and good to go. 30 00:01:09,330 --> 00:01:12,660 ‫Next, we need to choose some application code. 31 00:01:12,660 --> 00:01:14,070 ‫So we'll use a sample application, 32 00:01:14,070 --> 00:01:15,630 ‫we can definitely upload our own code 33 00:01:15,630 --> 00:01:17,040 ‫but we don't have that right now. 34 00:01:17,040 --> 00:01:18,183 ‫And so, this sample application 35 00:01:18,183 --> 00:01:22,320 ‫will be matching the environment I have right here. 36 00:01:22,320 --> 00:01:24,262 ‫Okay, so let's scroll down, we have presets, 37 00:01:24,262 --> 00:01:26,760 ‫and Beanstalk can be quite complicated 38 00:01:26,760 --> 00:01:28,530 ‫for the configuration and as such, 39 00:01:28,530 --> 00:01:30,540 ‫we can set recommended values 40 00:01:30,540 --> 00:01:33,720 ‫for either a single instance, which is free tier eligible, 41 00:01:33,720 --> 00:01:36,090 ‫or high availability, where we have a load balancer, 42 00:01:36,090 --> 00:01:38,130 ‫for example, or custom configuration 43 00:01:38,130 --> 00:01:40,020 ‫if you wanted to customize everything. 44 00:01:40,020 --> 00:01:41,430 ‫Now to keep things simple, 45 00:01:41,430 --> 00:01:43,980 ‫we're going to go over single instance. 46 00:01:43,980 --> 00:01:45,153 ‫So we click on Next, 47 00:01:46,091 --> 00:01:47,550 ‫and next we have a tricky bit, 48 00:01:47,550 --> 00:01:49,770 ‫we need to configure the service access. 49 00:01:49,770 --> 00:01:52,590 ‫So it's the IAM roles that will allow Beanstalk 50 00:01:52,590 --> 00:01:54,360 ‫to do what it needs to do. 51 00:01:54,360 --> 00:01:55,290 ‫So it's very simple, 52 00:01:55,290 --> 00:01:59,250 ‫we can just go ahead and create a new service role, 53 00:01:59,250 --> 00:02:02,580 ‫and this will create the Elastic Beanstalk service role. 54 00:02:02,580 --> 00:02:04,230 ‫Now, I think that right now this is a new console 55 00:02:04,230 --> 00:02:06,930 ‫so there may be a bug, and this is not prefilled 56 00:02:06,930 --> 00:02:09,240 ‫so we need to go ahead and create manually 57 00:02:09,240 --> 00:02:11,490 ‫the EC2 instance profile. 58 00:02:11,490 --> 00:02:14,943 ‫So as such, I'm gonna go into the IAM console, 59 00:02:15,951 --> 00:02:17,280 ‫and on the left hand side, 60 00:02:17,280 --> 00:02:20,610 ‫I will go into Roles and I will create a role. 61 00:02:20,610 --> 00:02:25,610 ‫And it's for a service, it's for EC2, you click on Next. 62 00:02:26,160 --> 00:02:28,470 ‫Then, for permissions policy, you just filter 63 00:02:28,470 --> 00:02:30,540 ‫and you type in Beanstalk 64 00:02:30,540 --> 00:02:33,420 ‫and you need to add the web tier, 65 00:02:33,420 --> 00:02:38,340 ‫the worker tier, and the multi container docker. 66 00:02:38,340 --> 00:02:41,160 ‫This should be enough to get started. 67 00:02:41,160 --> 00:02:45,060 ‫So we click on Next, and then for the role name, 68 00:02:45,060 --> 00:02:50,047 ‫enter AWS, then Elastic Beanstalk EC2 role 69 00:02:51,000 --> 00:02:52,950 ‫with hyphens in between. 70 00:02:52,950 --> 00:02:56,350 ‫Okay, so now we go ahead and we create this role 71 00:02:59,940 --> 00:03:01,320 ‫And this role right here 72 00:03:01,320 --> 00:03:04,500 ‫is going to be the one we're using in Beanstalk. 73 00:03:04,500 --> 00:03:07,380 ‫So I'll go back here, I refresh this, 74 00:03:07,380 --> 00:03:08,790 ‫and as you can see, it got prefilled, 75 00:03:08,790 --> 00:03:11,490 ‫so the Elastic Beanstalk EC2 role. 76 00:03:11,490 --> 00:03:14,310 ‫So once you've done that, you're good to go. 77 00:03:14,310 --> 00:03:15,870 ‫If you clicked on Next, 78 00:03:15,870 --> 00:03:18,930 ‫you would have to go over networking and database 79 00:03:18,930 --> 00:03:21,210 ‫and instance traffic scaling, all these kind of things, 80 00:03:21,210 --> 00:03:22,500 ‫but they're optional. 81 00:03:22,500 --> 00:03:23,700 ‫And right now, the thing we're going to do 82 00:03:23,700 --> 00:03:26,103 ‫is just click on Skip to review, 83 00:03:27,960 --> 00:03:30,540 ‫because we just wanna use the defaults that were set 84 00:03:30,540 --> 00:03:32,460 ‫for the single instance mode. 85 00:03:32,460 --> 00:03:33,990 ‫So make sure under Service Access 86 00:03:33,990 --> 00:03:36,030 ‫that you do have the service role 87 00:03:36,030 --> 00:03:38,550 ‫and the EC2 instance profile selected. 88 00:03:38,550 --> 00:03:39,960 ‫And when you're good to go, 89 00:03:39,960 --> 00:03:42,330 ‫you can definitely look at those, but they're complicated. 90 00:03:42,330 --> 00:03:44,280 ‫Click on Submit, and this will go 91 00:03:44,280 --> 00:03:47,253 ‫and create our first Beanstalk environment. 92 00:03:48,240 --> 00:03:50,040 ‫So now if we scroll down under Events, 93 00:03:50,040 --> 00:03:52,740 ‫as we can see, some events are happening 94 00:03:52,740 --> 00:03:55,680 ‫and these events actually come from a service 95 00:03:55,680 --> 00:03:57,810 ‫called CloudFormation. 96 00:03:57,810 --> 00:04:00,870 ‫So if you go into the CloudFormation console, 97 00:04:00,870 --> 00:04:04,110 ‫we have a look that indeed there is a stack created 98 00:04:04,110 --> 00:04:05,940 ‫that has been created by Beanstalk, 99 00:04:05,940 --> 00:04:08,100 ‫and this service, CloudFormation, 100 00:04:08,100 --> 00:04:11,610 ‫is allowing us to create resources behind the scenes. 101 00:04:11,610 --> 00:04:14,070 ‫So I won't go over too much of it, but like as you can see, 102 00:04:14,070 --> 00:04:17,490 ‫events describe how the CloudFormation template 103 00:04:17,490 --> 00:04:19,380 ‫is being created. 104 00:04:19,380 --> 00:04:22,082 ‫And if you go under Templates, 105 00:04:22,082 --> 00:04:25,140 ‫this is the template that generated our application, 106 00:04:25,140 --> 00:04:26,850 ‫and View in Designer, 107 00:04:26,850 --> 00:04:28,380 ‫we actually have the option 108 00:04:28,380 --> 00:04:30,690 ‫to view the kind of architecture 109 00:04:30,690 --> 00:04:33,000 ‫that is being created by CloudFormation. 110 00:04:33,000 --> 00:04:34,740 ‫As we can see, we have an auto scanner group, 111 00:04:34,740 --> 00:04:38,460 ‫a security group, a launch template, an Elastic IP, 112 00:04:38,460 --> 00:04:40,890 ‫and a few more things called weight conditions. 113 00:04:40,890 --> 00:04:42,960 ‫So I don't want to linger too much over it, 114 00:04:42,960 --> 00:04:45,333 ‫but the idea is that all the resources 115 00:04:45,333 --> 00:04:48,458 ‫that Beanstalk wants to create are actually created 116 00:04:48,458 --> 00:04:51,840 ‫behind the scenes by CloudFormation. 117 00:04:51,840 --> 00:04:55,290 ‫So in the Events tab, as we can see now, 118 00:04:55,290 --> 00:04:57,030 ‫we have some information, for example, 119 00:04:57,030 --> 00:04:59,820 ‫a security group was created 120 00:04:59,820 --> 00:05:03,090 ‫and then an Elastic IP was created. 121 00:05:03,090 --> 00:05:06,390 ‫Then we wait for the EC2 instances to launch, 122 00:05:06,390 --> 00:05:08,520 ‫and then the instances will be created. 123 00:05:08,520 --> 00:05:13,520 ‫So if I switch now and I go under EC2, the EC2 console, 124 00:05:14,790 --> 00:05:17,910 ‫and look at my instances running, actually yes, 125 00:05:17,910 --> 00:05:20,820 ‫one of my instances is running, 126 00:05:20,820 --> 00:05:23,220 ‫it's using a T3 micro. 127 00:05:23,220 --> 00:05:24,630 ‫And as we can see, 128 00:05:24,630 --> 00:05:28,140 ‫this instance has a public IP address right here. 129 00:05:28,140 --> 00:05:31,320 ‫And if I go on the left hand side under Elastic IPs, 130 00:05:31,320 --> 00:05:34,650 ‫we can see that this Elastic IP address was created 131 00:05:34,650 --> 00:05:38,340 ‫and is allocated to our EC2 instance. 132 00:05:38,340 --> 00:05:40,620 ‫And if I go under Auto Scaling groups, 133 00:05:40,620 --> 00:05:43,650 ‫we can see that an auto scaling group was created, 134 00:05:43,650 --> 00:05:47,010 ‫and this auto scaling group, under Instance Management, 135 00:05:47,010 --> 00:05:49,560 ‫is managing my only EC2 instance, 136 00:05:49,560 --> 00:05:52,050 ‫that's why it's called a single EC2 instance. 137 00:05:52,050 --> 00:05:53,888 ‫So all of this makes sense 138 00:05:53,888 --> 00:05:56,820 ‫and that's why Beanstalk is created. 139 00:05:56,820 --> 00:05:58,260 ‫And at the end of it, 140 00:05:58,260 --> 00:06:00,240 ‫when everything is launched, you'll say, okay, 141 00:06:00,240 --> 00:06:03,420 ‫successfully launched and it will be Ok for Health. 142 00:06:03,420 --> 00:06:05,850 ‫And what we get out of it is a domain name. 143 00:06:05,850 --> 00:06:07,440 ‫So if I click on this domain name 144 00:06:07,440 --> 00:06:08,893 ‫and open it in a new tab, 145 00:06:08,893 --> 00:06:13,320 ‫I get actually access to my Beanstalk environment 146 00:06:13,320 --> 00:06:15,090 ‫and my single EC2 instance. 147 00:06:15,090 --> 00:06:16,680 ‫And it says, "Congratulations, 148 00:06:16,680 --> 00:06:18,600 ‫you are now running Elastic Beanstalk 149 00:06:18,600 --> 00:06:21,450 ‫on this EC2 instance," which is amazing. 150 00:06:21,450 --> 00:06:23,670 ‫So as you can see, very simply, 151 00:06:23,670 --> 00:06:26,479 ‫Beanstalk was creating for us, just from the code, 152 00:06:26,479 --> 00:06:29,070 ‫the sample code that we were using, 153 00:06:29,070 --> 00:06:31,620 ‫it generated all the infrastructure 154 00:06:31,620 --> 00:06:35,040 ‫to start successfully my application, my web server, 155 00:06:35,040 --> 00:06:37,230 ‫which is very, very good. 156 00:06:37,230 --> 00:06:39,090 ‫So now, let's have a look at a couple of options. 157 00:06:39,090 --> 00:06:42,780 ‫So if we wanted to upload a new version, we click on here, 158 00:06:42,780 --> 00:06:44,190 ‫we could upload a new version 159 00:06:44,190 --> 00:06:48,660 ‫and automatically it would be deployed to my EC2 instances. 160 00:06:48,660 --> 00:06:51,390 ‫So we don't have that, but just to give you an overview, 161 00:06:51,390 --> 00:06:53,160 ‫health gives you some information 162 00:06:53,160 --> 00:06:55,140 ‫around the health checks of all your instances, 163 00:06:55,140 --> 00:06:56,700 ‫if you had many. 164 00:06:56,700 --> 00:07:00,390 ‫You can go under Logs to view the logs of your application. 165 00:07:00,390 --> 00:07:01,530 ‫You can go under Monitoring 166 00:07:01,530 --> 00:07:04,290 ‫to have a look at all the metrics for your application, 167 00:07:04,290 --> 00:07:07,050 ‫so we get really like some view centric 168 00:07:07,050 --> 00:07:09,630 ‫around all my application itself. 169 00:07:09,630 --> 00:07:11,820 ‫The alarms, manage updates, 170 00:07:11,820 --> 00:07:14,130 ‫which is when Beanstalk decide to update 171 00:07:14,130 --> 00:07:15,990 ‫our entire environment. 172 00:07:15,990 --> 00:07:18,360 ‫And then, if you click on Configuration, 173 00:07:18,360 --> 00:07:21,480 ‫you can actually have a look at all the configuration 174 00:07:21,480 --> 00:07:24,900 ‫of your Beanstalk environments, modify them and apply them, 175 00:07:24,900 --> 00:07:27,780 ‫which are quite, quite well rounded 176 00:07:27,780 --> 00:07:29,970 ‫but we don't need to know about this right now. 177 00:07:29,970 --> 00:07:34,170 ‫Now, more importantly, if we go under MyApplication, 178 00:07:34,170 --> 00:07:37,020 ‫as we can see right here, there is MyApplication-dev, 179 00:07:37,020 --> 00:07:38,520 ‫that's one environment, 180 00:07:38,520 --> 00:07:41,520 ‫but I could go ahead and create a second environment, 181 00:07:41,520 --> 00:07:43,080 ‫for example, MyApplication-prod, 182 00:07:43,080 --> 00:07:44,580 ‫and that will allow us 183 00:07:44,580 --> 00:07:47,760 ‫to really think about environments overall. 184 00:07:47,760 --> 00:07:51,810 ‫So that's it for an overview of Beanstalk. 185 00:07:51,810 --> 00:07:53,600 ‫So to reason about it, 186 00:07:53,600 --> 00:07:56,880 ‫Beanstalk is centered around code 187 00:07:56,880 --> 00:07:58,680 ‫and environments for your code, 188 00:07:58,680 --> 00:08:01,050 ‫whereas if you wanted to look at CloudFormation, 189 00:08:01,050 --> 00:08:03,120 ‫the service we had seen before, 190 00:08:03,120 --> 00:08:06,570 ‫CloudFormation is used to deploy stacks arbitrarily 191 00:08:06,570 --> 00:08:09,270 ‫with any kind of infrastructure. 192 00:08:09,270 --> 00:08:12,090 ‫So we've seen all that Beanstalk has created, 193 00:08:12,090 --> 00:08:13,410 ‫including my auto scanning group, 194 00:08:13,410 --> 00:08:16,140 ‫my EC2 instance, the Elastic IP, and so on. 195 00:08:16,140 --> 00:08:18,690 ‫And so, if you are in a course 196 00:08:18,690 --> 00:08:20,730 ‫that has more Beanstalk lectures, 197 00:08:20,730 --> 00:08:23,550 ‫such as, for example, the Certified Developer course, 198 00:08:23,550 --> 00:08:26,760 ‫then do not delete your application, we'll be using it more. 199 00:08:26,760 --> 00:08:30,090 ‫But if you are done with the Beanstalk lectures, 200 00:08:30,090 --> 00:08:31,980 ‫you've known enough for the exam. 201 00:08:31,980 --> 00:08:35,250 ‫So what you can do is take your application, do Action, 202 00:08:35,250 --> 00:08:37,140 ‫and then Delete application, 203 00:08:37,140 --> 00:08:38,730 ‫and then you will have cleaned up. 204 00:08:38,730 --> 00:08:40,800 ‫So that's it, make your own call 205 00:08:40,800 --> 00:08:42,993 ‫and I will see you in the next lecture.