Hi friends! I'm going to start this video with a story. This is Sophia.
She's working for a startup that's creating a website and a mobile app that shows the location of air pumps for tires, like this one. Her boss, Alex, who wears sunglasses indoors apparently, came up with this idea after he had a low tire on his car one day and had to drive all over town looking for a gas station that had an air pump. Because they're a startup, they're on a shoestring budget, Sophia's uncle had an old Windows server sitting in his garage, so he donated that to the cause. It sits at the back of their co-working space, and that's what they're currently using to host things.
One day, someone on Reddit mentions their humble little site, and it starts to get more traffic. The server gets totally overwhelmed and promptly crashes. Sophia tells Alex the news, and he starts stressing about how they're going to buy new servers to manage the increased website Sophia's worked with AWS a little bit in the past and suggested they consider switching to the cloud. She tells him that rather than hosting their application on a single server in their office, they can use a server in AWS instead called an EC2 instance.
EC2 stands for Elastic Compute Cloud. The two is for the two Cs in there, if that's not obvious. And this is essentially a virtual server that you quote unquote rent in AWS.
Rent meaning that you only use it when you need it and you only pay for what you use. And in AWS speak, these are called instances. There's a lot of benefits to EC2.
First, it's easy to scale, meaning if you suddenly need 10 extra servers to handle increased traffic, it's easy to spin those up. And that can even happen automatically with a feature called auto scaling. EC2 is reliable.
Amazon has billions of dollars of infrastructure around the world. And if one of your servers goes down for whatever reason, it can automatically be replaced with another one. EC2 is one of the foundational AWS services. And as such, it works seamlessly with all of the other AWS services like networking, storage, security, and so on.
And as mentioned a minute ago, you only pay for what you use. So rather than guessing how many servers you need, and buying them and shipping them and setting them up and so on, all of that has a lot of upfront cost. Here, you just use the EC2 instance when you need it, and you only pay for what you used.
Now, let's go create an EC2 instance in the AWS console. There are seven steps and we'll talk through them as we get to them. Here I am in the AWS management console. If you need a quick video about how to set up an account and get logged in, then check out the video linked above. There's two different ways to get started with EC2.
First you can come down and expand all services and it's the first one right here under compute or if you're looking up here under this menu come down to compute and EC2. I'll click into that. And here on the EC2 dashboard we're going to launch our first instance, the orange button right here, Launch Instance.
You'll see the steps enumerated up on the top. We're at the first one of choosing our AMI. So an AMI or Amazon Machine Image is your basic unit of deployment in EC2. Without the AMI you really don't have anything. As you see at the top it has an operating system, an application server, and other software installed that'll vary depending on what type you choose.
There's lots of AMIs provided by AWS. There's also several available from the community in the marketplace, and you can create your own even. But scrolling down, you'll see the options here, several available for Linux, Mac, Red Hat, Windows, and so on.
A lot of different options here. The server we're replacing for Sophia was Windows, and this one is free tier eligible, the Microsoft Windows Server 2019 base. So we're going to go with that. Over here, choose Select.
Now we need to choose our instance type. These types have different combinations of CPUs and memory, networking capacity, storage, and so on, and they're grouped into families like you see here. If you click on the Learn More up top, this will take you to a page that gives you a lot more detail about what the different families are for.
You can click through here and see them. There's things that are compute optimized, memory optimized, and so on and so forth. All right, for our purposes, we want to choose the T2 Micro, which also is free tier eligible.
And then we'll come down to next configure instance details. There's quite a few details on this page here, settings around pricing and networking and access management and shutdown behavior. I'll call out a few things as we go. But you'll see there's also really handy tooltips here.
And some of them also have links where you can learn more. So check those out as you're going along. But starting up here, we're just going to create one instance from this AMI.
You can, though, create multiple instances if you want. Moving down the page spot instances have to do with billing. And with these you basically specify or bid on the amount that you want to pay. These can potentially save you some money.
But for our purposes, we're going to skip that. Moving down to the networking section, you choose your VPC or virtual private cloud. This is your virtual network that's logically isolated in a part of AWS, you should have one by default, like I do here, that's what I'm going to go with.
But you could also create a new one from here as well. And then additional details around subnets, IPs, hostname, DNS hostname, and so on. Once again, I'm just going to go with all the defaults and scroll down. The placement group and capacity reservation, these have to do with how your instance is logically grouped within an availability zone and the capacity you want to hold for it.
We're going to leave these as defaults as well. And same goes for this section, domain join directory and IAM role. These have to do with access and permissions. Moving down, I do want to call out the shutdown behavior here.
You'll see that there's two options, stop and terminate. Stop means that the instance is temporarily shut down and that you're going to use it again later. When you have an instance that's backed by an Elastic Block Store or EBS volume, kind of think of that as the C drive on your regular computer, if you stop your instance, that EBS volume remains so that it's ready to go next time you start the instance.
All of your data and everything will still be there. If you terminate the instance, though, that's permanent. the instance is shut down and your EBS volume is deleted. So in most cases, you're going to want to go with stop.
And I'll choose that. There's some additional options here, we'll go with the defaults as well as the advanced details, we'll go with defaults here. And then next up, we'll add storage.
I mentioned a minute ago, the EBS or elastic block store volume, this is where you specify that. So by default, we're getting a general purpose solid state drive, that's 30 gigabytes. You can change the volume type if you want or update some of these other settings.
You can also add new volumes if you need them. But we're going to go with it and go next to add tags. Tags are a really useful way to organize and manage your resources.
So maybe this machine is going to be used for development only as opposed to testing or production. So let's add a tag for environment and our value will be dev or development. And we're going to apply this to the instances, volumes, and network interfaces and say next configure security group. Security groups are basically your firewall rules that allow or disallow traffic for your instance. We're going to create a new one and then you want to add your rules.
So for example if we were hosting a public website here we'd need to go in and specify http for example, access on port 80, and you continue with the same for other rules that you need. but I'll get rid of that one. The default rule that was added for us is the remote desktop access on port 3389. And the source here with the zeros, that basically means that we're opening up access to any IP address to RDP into our server. Generally, this is not a good idea.
That's why you're getting the warning here. As a best practice, you want to restrict this to only known IP addresses. But for what we're doing, we're going to proceed to review and launch. All right here, review all of the details. You'll see we're still getting that warning about having the RDP open to the world.
Again, in the real world, you would want to change that. But everything else looks good here, and we're going to say launch. Next, we're going to be prompted for a key pair. And this is required to log into the instance, which we're going to do by remote desktop once it's launched. We'll go ahead and create a new one.
The key pair name, I'll say myttt for tiny technical tutorials, key pair. And then you're going to need to download it. I'll browse to the demo folder that I have and say save and then launch instances.
It'll take a minute or two for everything to launch. You can view the launch log here to see what's going on. There's some other links you can check here while you're waiting, but you can also view instances.
This will take you to the list of instances in the EC2 console and you'll see here status check it's initializing. and Instant State is running. We'll give this just a little bit longer. While we're waiting, though, if you're enjoying the content, be sure to hit that Like button for me and also subscribe so you're notified of new things as they get uploaded.
All right, I'll come up here and refresh. We still have initializing status check, you can click on this though, and down here below, you'll see all of the details of the instance. A lot of information here.
There's also additional tabs, security, networking, storage, and so forth. So here's where you can manage all the information about your instance. You can also do this through the command line interface or the CLI, or programmatically as well. Alright, I'm going to pause the video, let this finish and I'll be right back.
Okay, I'm back. Everything looks good here. Now what we want to do is connect to our instance.
Let's go log in and see what we got. I'll select the instance and then click on connect. There's a few different ways to connect to your instance.
We're going to go with the RDP client, remote desktop client here, and click on download remote desktop file. This will create a shortcut basically that you just need to click on and it's going to connect you to our instance. I'll save that on my hard drive. Pulling that up over here, I'll just double click this and we'll say connect.
Here you're prompted for the administrator password. So you might remember that key pair that we were working with before. We need to go get the password using that.
So we'll click on get password here, browse for that key pair file, the dot PEM file and open. Then we need to decrypt password. Here it is here, I'll copy that and then back to our RDP client. I'll paste in the password here and hit OK. Once again we'll say yes and here's our Windows server in the cloud.
Wait for everything to load here and there you go. Here's where you can do your development work or hosting or whatever you need to do. I'm sure Sophia and Alex would be very happy about this. Obviously this works for instances other than Windows and the Remote Desktop protocol, so if you're using Linux or Ubuntu or whatever the case may be, you can connect to those instances as well.
Now before you leave, let me just X out of this Remote Desktop session. If you're following along, I want to make sure you go delete your instance. We are using the free tier, but no sense in leaving things running out there unnecessarily.
So back here to your instances, go ahead and select this instance state and terminate instance. Remember, this is a permanent action, your instance will be shut down and your EBS volume or kind of your virtual hard drive is going to be deleted as well. So you get this warning just to make sure you really want to do this, we'll say terminate, instance state is shutting down, this might take a minute or two, and it will appear here as terminated. for a while but it'll eventually drop off your list.
I hope you enjoyed the video and learned something new. Let me know in the comments what you want to learn next. Thanks so much for watching.