2.1 EC2: Amazon's Virtual Servers
One of the most popular services on AWS is the Elastic Compute Cloud, or EC2. In this lesson, we'll go beyond the standard features and find out what makes EC2 special.
1.Introduction3 lessons, 13:15
2.Amazon Web Services10 lessons, 1:17:39
3.Conclusion1 lesson, 01:25
2.1 EC2: Amazon's Virtual Servers
Hi, welcome back to Explore Amazon Web Services. In this lesson, we'er going to look at one of the, if not the most popular service on AWS, the Elastic Compute Cloud, or EC2. In the heart, EC2 is just a platform as a service from Amazon. You can also get this at DigitalOcean or Linode, but they added quite a few features to make it possible to have a very large number of instances working together. Let's create an instance first. You have seen me do this in the overview lesson, but this time I'm going to explain every step of the way. First you have to choose an AMI, which is short for Amazon Machine Image. Those AMIs are the base point of your system. You can think of it as a preconfigured service that just needs some instance specific set up to be done on first boot. The most basic ones are [INAUDIBLE] operating systems. That's arranged from various Linux distributions, which includes an Amazon Linux that is designed to work great in the AWS environment. To various specific preconfigured implication images that may add additional cost to your instance, but this course normally covers license. There are also a lot of free AMIs on the marketplace. When you look at content management you can see at the top pre-configured instances for WordPress or Ghost. When you look at the detail page, you can also see how much an instance costs you with the added cost of the software. In this case, of course, the software is free. After choosing an AMI, you have to choose your instance type. This can go from a micro instance, which you can run for free in the first year with just one virtual CPU and 1GB of ram. To extremely powerful number crunchers with 32 virtual CPUs, 244GB of RAM, and eight times 800GB of SSD storage. Amazon offers very specifically designed instances. You can have some that have 40 virtual CPUs but no real storage, or some that have 24x2 TB of storage. There are also GPU instances. After you choose an instance type you can configure how many instances you like. I'll create 5 here. In which network [INAUDIBLE] run, you can create individual virtual private networks to isolate them from each other from the world. Specific subnets, public IP addresses, and your IAM roles. You can also decide if you want to run it on a dedicated hardware or share a host with others. Then you have to add storage. EBS volumes can be detached from an instance and reattached to another instance, which makes it easy to preserve data when upgrading an instance to a larger one. You can also set text specific to the instance, like the Name. Then you have to set up a security group. A security group basically acts as a firewall that opens specific ports up to the wold to your other instances. It works inbound as well as outbound. For a web or application server, you probably want to give the world access to HTTP and HTTPS ports. I could restrict access for SSH just to my IP address. But I'm in a setting where I can't be guaranteed to have the same IP address forever, so I keep it open. Before you create your instance, you can review all your settings and change them if you need to. And when you're ready to launch you will get asked one final question. The key pair the instance uses to authenticate you when you connect to it via SSH. You can either use a key that is already in the system or create a new one. Those keys are, like almost everything, dependent on the region. You can't use another region's key. When creating the key you get to download the key pair. You won't be able to able to download it another time. After launching, you will see the five servers in the list. They are currently initializing. While this is happening, let me take the time to introduce you to Spot Instances. Given a case that you need a lot of computing power, but it isn't time sensitive and you have a limited budget, you can use Spot Instances. Those are basically Amazon's attempt of maximizing use of available resources. By using Spot Instances, you specify a price limit on how much you want to pay for your instances and a few other details that give you a request. The price is normally quite a bit lower than normal instances. When Amazon has available computing power, it drops its prices. When many people are using EC2 the prices rise. If the current rate for an instance drops below your limit, your request will be processed and you receive the requested instances at the lower price. When the prices rise above the limit again, your instances will be terminated. As you can see, prices vary quite a bit by instance type and availability zone. Additionally to the maximum price, you can also supply a date range in which the request should be valid. And if it should be reissued if your instances were terminated. All the rest is similar to a regular instance Now, our request shows up in the list and will be fulfilled if the price drops below our limit. Let's see how the instances we set up are doing. It looks like they're all done. When you look at the details of an instance, you can see its connection data like public DNS name and public IP. We can use these to connect to our instance. Note that these change upon each restart of the server unless you attach an elastic IP to it. After connecting via SSH, you can see it's just a basic Linux system. When you want to get rid of an instance, you can terminate it. I'm going to terminate all five of them at once. If you just want to save money, you can also stop an instance. It doesn't cost anything if your instance's not running. Now let's have a quick look at Key Pairs. As you can see, you can import a key to be used inside AWS. It is very handy, as you can use the same key for all regions. Elastic IPs, as I mentioned before, are fixed IP addresses that you can associate with an instance, so it doesn't change upon start. Very handy if you are pointing at the main record at an instance. The last thing I want to show you is reserved instances. If you can plan ahead and know your usage over next year or longer, you can use reserved instances. Those are generally cheaper per hour, but you will have to sometimes pay all or a partial sum upfront and can't cancel the instance before it's expiration date. You now know about running EC2 instances, setting security groups, and static IPs, and how to make spot instance requests. In the next lesson, we are going to learn about EC2 container services, a relatively new addition to AWS that allows you to run containers. See you there.