Okay.
Hello bloggers and welcome to this lecture and this lecture we're going to look at launch configurations
and auto scaling groups and the best way to learn about launch configurations and auto scaling is to
go ahead and get your hands dirty.
So let's log into the adobe us console.
Okay so I'm in the adobe Adobe's console.
Do go.
Feel free to go ahead and delete your load balancer so you can go ahead and just hit delete.
Then you go over to your target groups.
You're going to have to wait a little bit to delete the target group.
I think so far go ahead and hit delete.
Now I might get an error message note that worked and then I'm just gonna go up here and delete my easy
two instances as well.
And then what we're gonna do is we're gonna go ahead and we're going to provision an auto scaling group.
So just go in and hit terminate and yes terminate.
So those are now terminated.
I'm gonna go over to auto scaling.
So auto scaling if you scroll down is down here it's under load balancing and in order to create an
auto scaling group first thing we need is a launch configuration.
So in here we've got our launch configurations we're gonna go ahead and hit create launch configuration
we're gonna use the amazon Linux 2 a.m..
And we're going to use a T2 micro.
I'm gonna go ahead and configure our details so in here we're going to call it my ASG.
So auto scaling group launch configuration.
And in here the IAM role you can give it a particular IAM role so you could give it S3 admin access
for example in here we've got our advance details.
So this is where we would pass a bootstrap script.
Okay.
So this is the bootstrap script that we're going to use.
It's very similar to the last one that we used but we've just changed it to web server one web server
to two to just welcome to the easy to fleet.
So let's go ahead and copy that entire clipboard.
It's available in the resources section of the course.
And I'm gonna go ahead and paste that in here and then down here it says IP address type so you can
only assign a public IBM to address type 2 instances launched in the default BPC and subnet.
Or you could do it so that you assign a public IP address to every instance or you could say hey don't
assign public IP addresses.
I'm just gonna leave it as the default.
Let's go ahead and add our storage.
So we're just gonna leave it as default.
We only need eight gigs in here select an existing security group.
You want it new web DMZ.
Go ahead and hit review and then go ahead and create the launch configuration and you will need to say
that you've got access to your key pair.
Now doing this doesn't do anything.
It's just a launch configuration.
Hasn't launched any easy two instances.
However we can create an auto scaling group using this launch configuration and that will start to deploy
our easy two instances.
So in here we could call it a cloud guru ASG so that's our group name ASG is just auto scaling group
using the ASG launch configuration group size.
Let's start with a minimum of let's say three instances.
Gonna put it into our default VPC in here we've got our subnets.
If you go ahead and just click in all of them it will use randomly assigned subnets and if you're launching
three it is intelligent enough not to just put them all in one subnet it will spread them evenly out
across an availability zone.
And here we have our advance details so we can go ahead and put these behind an elastic load balancer
with health checks.
I'm not going to go ahead and do that just yet.
We'll do that in the WordPress section of the course.
And I also just deleted my load balancers as well.
So let's go ahead and hit next and then we can say keep this group at its initial size or use scaling
policies to adjust the capacity of this group.
And if we do this we can start creating policies to allow our or our easy two instances to scale out
in the event that there's going to be a lot of traffic.
So I'm going to see but scale between three and let's say between six instances so you can change the
metric type I'm going to use the average CCU utilization the target value is as soon as it goes above
80 per cent.
Then it's going to start scaling out and then in here instances need 300 seconds to warm up after scaling
and this is basically the amount of time your instances need to warm up during this time.
Instances that have been launched will not contribute to the auto scaling metrics.
So bear that in mind as well.
If we leave it as 300 then it will take five minutes before they contribute towards the metrics.
I'm going to see and just do that for 60 seconds rather than 500 that second sorry 300 seconds which
is five minutes.
So let's go ahead and hit next to configure our configurations in here we can add a notifications that
could send us an Aston s notification I'm not going to do that in terms of our tags I'm just going to
say name my ACG so my auto scaling groups and go ahead and hit next and then I'm going to go ahead and
create my order scaling group.
Okay so that has now created successfully if I just maximized this down here I'll be able to go in and
have a look at my activity history second since launching three easy two instances and you'll be able
to see two instances in here I've already got two in service.
This one's pending they go up to my dashboard.
I'll be able to see it and I've got my two running instances I've got one that's still coming up online
and I've just hit refresh and these are all up online now.
So if we go in we could go in and start trying to stress out the CPSU or we can go ahead and simulate
a fail over.
So let's go ahead and delete some instances and see what happens.
So we've got our instant state in here.
We're going to go ahead and terminate it.
I'm going to terminate one in UST e one 1A and I'm going to terminate another one in UST e 1 C and what
we'll do is we'll see whether or not our auto scaling group is going to detect that and how it's going
to go ahead and recover from that.
So I'm just going to pause a video I'm going to wait for these two instances to be terminated.
OK.
We can see that those two instances have now been terminated and if we hit refresh we can see another
instance is now up and running and I bet you if we just keep hitting refresh we'll be able to see another
instance very very soon.
So what auto scaling is doing is it's detecting that that has failed.
We go back over to our auto scaling groups we should be able to see this in the activity status and
in here we can see that it's terminated an instance and then it's gone on and launching a new easy to
instance and the reason for that is we have a minimum scaling policy if we have a look over here design
capacity 3 minimum of 3 maximum of 6.
So we should also get one more instance being provisioned as well.
But it can take a little bit of time to detect that it has failed.
And I think we have set that cooldown period for like 60 seconds as well.
So let's just I'm just going to pause video and wait.
It's been a few minutes.
Let's go ahead and hit refresh and there we go we've got our third easy to instant.
So it has gone in and fix that for us.
Also note that it's put it back into the same availability zone so we've it's been spread out evenly
across our availability zones so one A one B and 1 c.
You could also log into these three easy two instances and install a program that would max out the
CPSU if you want to go do that as an extra homework assignment you can.
I'm not going to I'm sure you get the point.
Basically it's going to scale up and add instances as as the need arises.
I mean to go through and delete this or auto scaling group now when you delete an auto scaling group
the instances beneath it will be deleted as well.
So we just go over to actions and hit delete and then hit delete and now or delete the auto scaling
group and start terminating all my instances and you can actually watch that just by going in here.
So that is it for this lecture everyone in the next lecture we're going to look at the principles behind
high availability and then what we're going to go on and do is we're going to make a highly available
WordPress site on eight of us.
And again it's a great way just to piece everything together that we've learnt so far.
We're going to be using Route 53 we're going to be using load balancers we're going to be using E2 we're
going to be using yes it's going to be using multi easy for ideas going to be using auto scaling groups.
We're going to be using admires a whole bunch of different AWB as a services and technology.
So if you've got the time please join me in the next lecture.
Thank you.