There are certain types of servers that you’d desire to have highly available, but the cost of running multiple servers would be a bit impractical.
In our scenario, we’ll setup a management instance behind a load balancer. The instance will be part of an auto scaling group, which will lauch a new instance in the event of a failure.
Here’s a diagram of what we’re building:
First, we’ll need to prep a server (install and configure desired tools in OS, etc) that will be used as the template for the management instance. Once prepped, we’ll create the AMI.
It is generally preferred to leave the No reboot box unchecked, as selecting it could technically lead to inconsistencies in the image.
After a bit, we’ll find our newly created AMI.
Next we’ll create a Load Balancer. For our purposes, The Network Load Balancer is the best option.
We’ll name the load balancer and listen on 3389. With the proper VPC selected, we’ll specify our availability zones.
Now, we’ll create a new target group, also on port 3389
We won’t register any targets yet- we’ll use the ASG for that. Just click next.
Ok, now we’ll create a launch configuration as a prerequisite for our auto scaling group. After clicking Create launch configuration, select our AMI, pick the instance size, name the AMI, etc…
After the launch configuration is complete, we’ll begin our auto scaling group. We’ll specify the subnets that we want to utilize. We also need to specify our target group.
Since we just want to keep 1 instance up at any given time, we’ll leave ‘keep this group at its initial size’ selected. The remaining steps involve notifications and tags, which can be used if desired.
To sum up, our autoscaling group will spin up 1 instance, and maintain 1 instance as long as the health checks come back OK. Proceeding at this step automatically spins up an instance.
After our new instance has initialized, making an RDP connection to our load balancer DNS name will connect us to the instance.
Now, the whole point of this was to have the instance recover in the event of failure. So, let’s make it fail by setting a static IP on the nic in Windows that is invalid…this will cause an instance check failure.
Saving those settings and things go down.
After a bit, we’ll see the instance checks fail.
The instance is eventually deemed unhealthy by the target group, then the autoscaling group. Then, it will be terminated and a new instance will be launched.
After the new instance has passed all of its health checks, we are able to connect via RDP to our load balancer DNS name.
…and that’s all there is to it.