Amazon AWS DevOps Engineer Professional – Incident and Event Response (Domain 5) & HA, Fault T… part 1
- Domain 5 – Coverage Overview
Okay, so we are getting to the domain five, and what I want to talk about really, really quickly is how much we’ve covered of domain five already. And that’s the reason why we’re not going to do some indepth on it, but we’ll do domain six in a second. So the first part of the main five is to troubleshoot issues and determine how to restore operations. So we’ve done that a lot. We’ve looked at Cloud Watch to look at logs, metrics, alarms and so on, cloud formation, to be able to deploy stacks in your region repeatedly, rollbacks using code deploy, et cetera. So all these things we kind of seen all along the course.
There’s also those two things you need to determine how to automate event management and alerting and apply concepts required to set up event driven automations. And this again, we’ve done. We’ve done a lot of Cloud Watch events. Every time I walk you through a service, I usually try to show you the integration with cloudwatch events just to prove to you that it is the centerpiece of all the automation of many Delete AWS services. We also have cloudwatch alarms to automate this kind of event driven animations and alerting, and finally sms to send some notifications to other services. So again, all these things have been covered in this course.
This is why we’re not going to do them in depth, because we already saw them in depth alongside the course. Now, there’s the last thing in domain five called automated healing. And we’ve seen this with cloud formation. For example, if we trigger cloud formation using an alarm or an event, then we could have some sort of automated healing. Definitely. If we use beanstalk, it’s most likely a lot easier because beanstalk has some concept of healthwatching for your instances and understanding what goes on. And so if you back it up by an odo scaling group, then you have automated healing. opsworks has this concept of automatic host replacement and will manage the infrastructure for you.
So if the opsworks agent doesn’t pass the health checks and doesn’t send heartbeats often enough, then there will be some automated healing happening on the opswork instance. And then finally, Otiscaling will see everything in this section. So asg is going to be the centerpiece of domain six. And so definitely with Otiskelling we have the concept of automated healing. And so this is what we’ll see in the next section, section domain six, which is in this section of this course. And we’ll learn so much about auto scaling because it is such an important service going into the exam. All right, so that’s it. Just to show you that we have covered domain five, even though there is no lecture dedicated to it in this course. And I will see you in the next lecture for domain six.
- ASG – From Launch Configuration
So let’s get started with Auto scaling groups. And we have a lot to learn. So in this section we’ll learn how to create an auto scaling group in two ways. The first one using Launch Configuration and the second one using Launch templates. But let’s get started with launch configurations because by now this should be what you are already familiar with. So we’re going to create a launch configuration and I’ll choose Amazon linux two hvm as my ami. I’ll click on select and then I’ll choose a T two micro instance. Just click on Configure Details and then I need to name my launch template. So I’ll call it web server launch configuration.
Sorry. And for the purchasing option I could request Spot instances. As we can see, we could have Spot instances, all part of the launch configuration. Or just on demand instances we could attach an iam role but I won’t attach anything right now. And then for advanced details we could set a user data. And so the user data we’re going to set for this section is going to come right here. So make sure to include from the very first line all the way to the end, it’s going to include a little bit of code which is going to install apache and then create two files. One file has been called index html and the other one is called Health html. Okay, this will basically create two files for our web server. Okay, so we’re good to go. Then I’m clicking on Add Storage.
The storage looks good. And for the configure security group, I’m going to create a new group and I’m going to have ssh and port 80 for Http. And I’m just going to name it Auto Scaling Group Security One. Okay, we’ll review this and create Launch configuration. And let’s get started. So this launch configuration is just a way to define how to create instances as part of your otis scaling groups. And if we can create an odor scaling group using this launch configuration, we can get to the next step. So I’ll call it Demo ISG and we can start with one instance. You can specify a list of subnets for these instances. And this is going to be based on your launch configuration that you have for advanced details we can have a load balancer, health check, grace period and we’ll see all these things in detail.
So for now we won’t do anything. Let’s click on next configure auto Scaling policies. We’ll keep this group at its initial size. We’ll have deep dives into scaling policies later in this section for Notifications team. We will do that later on. And for tags I’m just going to name it Demo ASG as name. And I’m going to show you something. So environment is going to be called Development. Okay, so Development, here we go. And so as we can see here, it says Tag new Instances. So what will happen is that here we set some tags for the auto scaling group, but these tags get passed on to the instances created by this auto scaling group. Thanks to this tick box right here. We’ll click on Review and we create our auto scaling group.
So now our auto scaling group is being created and it’s going to start one instance. So let’s wait for it to happen. So my instance is now launched and if I go to the instances tab, I can see that my instance is right here. So I’m going to go directly into my instance page. And as we can see, the state is running. So if we look at our ASG and we looked at the tags, we have Environment Development and name demo ASG. And for the instance itself, the name was demo ASG. And if you go to the tags, it did inherit the Environment development. Also there has been an added tag called aos Auto Scaling Group name which is demo ASG, which corresponds to the name we have given to this ASG sg right here.
Okay, now let’s look at our instance and see if it works correctly. So we have the public dns in here. I’m going to go ahead and copy this. So this gives us the index, and the index html is working. And then if we go to slash health html we have healthy. And so that means that the instance is saying that it’s healthy. We’ll use this do health checks later on. Just note that if you don’t type the html, things won’t work. So make sure to do type the html to get this healthy thing. Okay? So that’s it. Just for creating a natural scanning group using launch configurations. In the next lecture, we’ll see how to do this with launch templates.
- ASG – From Launch Templates
So here comes what I think something that you may not know already, which is launch templates. So launch templates is an advanced way of defining instances that you can start in different ways for your instances automatically or your auto scaling groups. So we’ll see how that works. But to me that is a revolutionary way of defining things because we’ll be able using launch templates to create an auto scaling group that has both ondemand instances and spot instances instances. So let’s create our first launch templates and here what we would like to do. We would like to create a new template. So there is this thing with templates in launch configurations that when you have a launch configuration and you want to update it, it creates a new launch configuration.
But with templates you can update the same template and create a new template version. So the idea is that now these templates are going to be versions and easier to find out which version corresponds to which templates. So this is something I really like and we’ll see this in the hands on as well. So we’ll create a new template and I’ll call it my demo templates. We can look at tags for this templates and we could add tags as well. So we could say name demo templates and then environment would be Developments okay, excellence. Then we can define the description. So it’s a my first version of a launch templates. Okay, next we can have a source template. So this is really cool.
You can specify a source template if you’d like to create a template from another existing template. So here if we had already created a template, we could source some parameters directly from a source template. So there’s this concept of hierarchy templates can have parents and so on, which allows you to define all the parameters you want up to a certain point. So this is fine. And in this launch template we can specify a lot of things. So the first thing we’ll specify is an ami ID. So we’ll go to quickstart and we’ll search for an ami and we’ll choose the first one amazon linux to ami hvm which is the hvm X 86 visualization. We’ll click on this one and then we could include but this is optional and instance type.
So in this case we could say okay, you could be a T two micro, right? But this is something we could optionally not set and then it would be obviously when we start launching an instance from it, it would be set. But this is up to us to choose whether or not we want to set an instance type. We’ll select one for this example, but the same goes with a key pair name. We can optionally not set it in this template. But here I’ll select aws devops. For the network we’ll choose vpc and here for the group security group again you could choose not to include one but we’ll just go and select this one, the auto scaling group that we have created. oops, this is good.
The auto scaling group we have created because it contains the Http rules, we could define network interfaces. So this is all the kind of things we’ve seen when we launch an easy to instance storage type and so on. Instance tag. So here we could say do you want the instance to be tagged as well? So I’ll call this one name instance Tag. And here. Environment, development. So something we can see here is that we can tag the instances and tag the volume. So this is added a feature of launch templates. And so these instance tags are different from the tags that we set for the launch template tags. Okay, good to know. All right, so we go down and in advance details we can request spot instances.
So we could say, okay, some of the instances may be spots, but right now we won’t do this. We could set an iam instance profile. We could set all these things right here. But what we’ll be setting will be all at the bottom. We’ll be setting some user data. So I’m going to go ahead and click on Copy and go back here and paste this in here. oops, here we go. We’ll create this launch template and now this launch template has been created. So from this launch template we are able to launch an instance directly from a launch template. Or we can create an auto scaling group from the templates, or we can create a Spot fleet. So as you can see from one launch template we are able to do multiple things.
Which is why I think that in the future, launch templates are going to be the norm for creating asgs easy to instances or spot fleets. Let’s close this. This is our launch template. We’ll right? Click on it and click on Create Auto Scaling Group. So we are taken into the auto scaling group. ui. But if we went ahead and just go to Auto scaling groups and click on Create Auto Scaling Group as we can see, as soon as we have a launch configuration and a launch template, it does give us this ui when we can select between launch configuration and launch templates. And the idea here is that launch templates are new.
They want you to be using launch templates from now on because they give you the option to launch one instance of the type or a combination of instance types and purchase options. So with this launch template it is possible for us to say I want some T, two micro, some T, two small, some C, three X large, and I want some of them to be on demand and some of them to be spot instances. So this is a much more flexible type of way of starting an auto scaling group, which I really like. So let’s go ahead with this launch template and we’ll take this box, click on Next step and I’ll call it Demo ASG Launch Templates. Okay, here we go. And here we select the launch template, the launch template version.
So we could say Default latest or one. We’ll just lose the one and then we can choose a defeat composition. So do we want to adhere to the launch template or do we want to combine a spot instances and on demand? So this is just good to know. Going into the exam, if you want to specify a mix of ondemand and spot instances for your ASG, then you need to use a launch template and you need to use this option. Okay? And this is something quite complicated to monitor if you want to specify so many parameters. But for now, we just know that this option exists, we won’t be using it and we’ll just click on adir to the launch templates. And this launch template was specifying the fact that we wanted a T two micro ondemand and it was not a spot.
We’ll start with one instance and we’ll select three subnets. Here we go. And for the events detail, we can also set same as before, load balancing, health check and so on. We won’t set anything right now. Click on scaling policies. something’s wrong. So invalid ID for this auto scaling group. So let’s go back to our launch template. Something must be wrong. So back into the launch template. It’s actually pretty cool because now we’re going to create a new version from it. So click on Create Launch Templates and I’m going to create a new template version from this one and the source template is going to be the one right here, and the source template version is version one. So now we’re saying, okay, create a new version from this template and here’s the source version.
And here if we scroll down something that was wrong is that, I don’t know, maybe the ui messed up something when I clicked it, but it has two security group. Obviously this first one exists because it’s a security group ID, but the second one doesn’t seem to exist. So I’ll remove this one and this was just probably ui bug, nothing I did wrong. So now we have only one security group, which is the correct one, and this should work. So let’s just go ahead and create this launch template. And this is quite nice because now we have a launch template. As you can see it’s the second one we have created and the default version is one. The latest version is two.
And so we can set the version two to see what goes on and so on. And we could right click and set the default version, for example, to be version two. So here we go. So this is quite nice because now we can version our templates and we can see all the templates by version ID and they’re grouped by what you want this template to do, which is a big improvement over to launch configurations here in the version tab. As a way you can see everything as well for the versions and you can click on them and so on. Okay, so back into our auto scaling groups. Hopefully this one. This should work. So let’s create a new auto scaling group launch templates.
I’ll select this one, click on Next step, and I’ll call it Demo ASG Launch Template. Here we go. We’ll launch it from this Launch template, version two, which is the default version, and we’ll adhere to the launch templates. We’ll start with one instance, select three subnets and not set any advanced details. Not click on next. And now it’s working. So we’ll keep this group at its initial size, notifications same, review the tag and so on. We could have tags here, but I think the launch template itself should tag new instances. So let’s see how it goes. Review and click on Create autoscaling Group. So now this auto scaling group is being created and we need to wait for the instance to come up.
Okay, so my instance has now launched, and if I go to the instance itself now, I should be seeing some information on it. Here we go. It has been created. As you can see, the instance did inherit the tag directly from the launch template. So this is quite interesting to see. And here we go. So everything looks good. Now we have even more tags regarding the EC two Launch Template ID and version. So even more information because we used Launch Templates. So this is definitely in the future for Amazon. And then security check, we’ll just go to the url. This is working in slash health index html. Sorry, this is working too. Okay, excellent. So we have created two auto scaling groups, one using a launch configuration and one using a launch template.
And what I wanted to show you in this case is that the launch template do give us the ability to specify a mix of instances, a mix of on demand or Spot for purchasing options. And so they’re much more powerful overall to use for Asgs and something you need to remember going to the exam. So Launch Templates is definitely, by the way, the future for Amazon. So we’d encourage you to start using them as soon as possible and migrate away from launch configuration into Launch Templates. Now, when we go ahead, I’m going to delete the one created with the launch configuration because we only using one auto scaling group in this course, and there will be the one created using a Launch template. All right, that’s it for this lecture. I hope you liked it and I will see you in the next lecture.