Compute Fundamentals for AWS
Elastic Compute Cloud (EC2)

Compute Fundamentals for AWS offers you an updated introduction to AWS's cornerstone compute services, and provides a foundation as you build your compute skills for AWS. It includes coverage of:

- Amazon Elastic Compute Cloud (EC2)
- Elastic Load Balancers (ELBs)
- Auto Scaling
- Amazon EC2 Container Registry and Services (ECR and ECS)
- AWS Elastic Beanstalk
- AWS Lambda

Do you have questions on this course? Contact our cloud experts in our community forum.


Welcome to Cloud Academy, Amazon Web Services Compute Fundamentals. This is an introductory course that will provide a high level overview of the offerings that comprise of AWS Compute Services, and will give you a basic foundation to build your knowledge upon in future courses.

During this course, we will cover the basics of Amazon Elastic Compute Cloud (EC2), Elastic Load Balancing, Auto Scaling, Amazon EC2 Container Registry (ECR), Amazon EC2 Container Services (ECS), AWS Beanstalk, and AWS Lambda. To be able to follow along with this course, you will need to have a computer with Internet access and access to an AWS account. After completing this course, you will be able to explain what the AWS Compute products and services are, choose the appropriate AWS Compute service or services for a specific requirement, and explain when a specific AWS Compute service may not be appropriate.

Amazon EC2 was released in 2006, and since then it has come a long way. It's a very powerful and mature product. EC2 allows users to provision virtual computers, called instances, on a pay-per-use basis that you can create, launch, and terminate these instances as needed and only pay for what you use. You have full control over the geographical location where the instances are provisioned and you can take advantage of resiliency by deploying into different availability zones within each of the regions. Before we go any further, let's familiarize ourselves with the EC2 dashboard.

From the AWS console, click on EC2 under the Compute section to go to the EC2 dashboard, and you will see that the EC2 dashboard is broken up into three sections. On the left hand side, there is a menu bar that you can use to navigate, access configuration hubs like instances, network, security, and auto scaling to perform advanced configurations that are related to your EC2 instances. On the right hand side, there is account information and links to your VPC, resources that you can use for help, and finally the AWS marketplace, where you can find pre-built and configured systems. The center column provides an overview of the resources that are currently running, the Create Instance section where you can launch the EC2 Wizard by clicking on the blue Launch Instance button, and the bottom half, the Service Health and Notifications of any scheduled events for the selected region.

The best way to learn is to do. But before we jump in and launch our instance, let's cover the steps that are required and also what you will need to take into account before beginning. There are seven steps in the process of creating an instance that are, step one, choose an Amazon Machine Image. When choosing your AMI, you have a choice of those that have been created by AWS, the community, AWS marketplace, or ones that you have created. It is important that you select the right image for your needs and you have a choice of current supported operating systems, as well as a number of Linux distributions. Step two, choose an instance type. AWS offers a wide selection of instance types with varying combinations of CPU, memory, storage, and networking capacity to give you the flexibility to choose the appropriate mix of resources for your purpose. Each instance type includes one or more instance sizes, allowing you to scale your resources to the requirements of your tagged workload. Note, this is the minimum information required to launch an instance. Step three, configure instance details. This allows you to launch multiple instances from the same AMI and instance type, request spot instances to lower your pricing, assign an access management role, configure shut down and termination behavior or advanced configuration using user data to configure the instance or run a scripted launch. Step four, add storage. This allows you to add additional storage to your EC2 instance, which will appear to your instance as local storage. Step five, tag instance. Tagss a case sensitive key value pairs that you can assign to an instance, and it is a very good practice to get into early on, specially as your environment grows, as you can filter on this value for reporting purposes. Some example of tags are role, purpose, assigning owners, etc. Step six, configure security groups. Security groups are firewall that controls traffic to your instance. At a minimum, you should define a rule that allows SSH for Linux over TCP port 22, or RDP for Windows, TCP port 3389, so you can access the server. Warning, you need to be careful when opening these ports as to where you can access them from, as a default source is, which is from anywhere. It is best practice to limit this to a dedicated IP address or a trusted range. Step seven, review instance launch. This is the final step and from where you can review all of the settings you have previously configured, and then launch the instance and verify that you have access to a key pair so that you will be able to log in to the server.

Now that you understand the steps, let's jump in and create our first instance. From the EC2 dashboard, click on the blue Launch Instance button to start. And from the Choose an Amazon Machine Image, you will notice on the left hand menu, you will see tabs for My AMIs, AWS Marketplace, and Community AMIs. If we go back to the Quick Start tab, you will also notice that there is a check box to select Free Tier Only. This is part of AWS's free tier, in which new customers can get started with Amazon EC2 for free. Do note that there are limits on this on a per monthly basis. However, this is more than sufficient for you to become proficient in EC2. For more information about AWS free tier, check out their website. For the purpose of this demo, we will just select the first Linux distribution and then click the blue Select button. We are then presented with Choose an Instance Page and you will recall that there are multiple instance types that we can choose and we can filter these to help narrow down our selection. For the purpose of this demo, we will select General purpose t2.micro and take advantage of the free tier.

You will recall that this is the minimum required information to launch an instance, and you can do that by selecting the blue Review and Launch button. However, for completeness sake, we will go through the remaining steps to illustrate some more details of which you should be aware. To go to the next step, click Next, Configure Instance Details button. Next we are presented with the Configure Instance Details page. I'm going to point out a couple of areas to be aware of.

Now some of the details in this step are covered in more detail in the intermediate and advanced courses. The first is that you can specify multiple instances of the AMI and instance type that you have previously selected to be deployed. The other is the shutdown behavior. When an operating system shutdown is initiated, there are two options here, which are Stop and Terminate. If you select Terminate, you will shut down the EC2 instance, will be destroyed, and will no longer be charged for usage. Additionally, any data that was stored locally on the instance will be lost and any attached EBS volumes will also be deleted, unless you specifically flag to not be deleted on termination. On the other hand, if you select Stop, when you stop the EC2 instance, you will no longer be charged for the instance usage. However, any attached bootable EBS volume will not be deleted and the data on your EBS volume will remain, whilst any information on the local ephemeral disk will be lost. The EBS volume will continue to persist in its availability zone and standard charges will be applied. The ability to stop an instance is only supported on instances that were launched on an attached EBS volume as an EBS boot petition, instead of being stored on the local instance. To prevent accidental termination of the EC2 instance, you can select the check box to enable termination protection.

Next, click Add Storage. On the Add Storage page, you have the option of adding additional storage to your EC2 instance. The top of the storage that you can add is instance storage, which is ephemeral storage and only exists as long as the instance is running. The other type is Elastic Block Storage, EBS, which is persistent storage.

Click Next Tag Instance to continue. As mentioned earlier, tags are a case sensitive key value pairs that you can assign to an instance. It's a good practice to tag instances as you can use these tags to filter long lists of resources for reporting and management purposes. If you don't assign a tag at this point, you can always come back later to update, to add one after it has been created.

Click Next Configure Security Group to continue. A security group is a firewall that controls traffic to your instance. And as mentioned before, you should define a role that allows SSH for Linux distributions over TCP port 22 or RDP for Windows over TCP port 3389, so that you can access and manage the instance. For the purpose of this demo, we will create a new security group and allow it access to SSH and limit the source IP to my IP address.

Once we have added the necessary rules, we will click Review and Launch. The final screen you are presented is a summary of the configured settings. And once you have confirmed that the settings are correct, click on Launch button, and you will then be prompted to select a key pair and acknowledge that you have access to the selected private key. Otherwise, you won't be able to log on to the instance. If at this point you don't have a key pair, you have the option to create one and download the file. But as I already have one, I will select the appropriate key and acknowledge that I have access to the private key file and then click Launch Instance, at which point the instance will be started.

Now that the instance has been launched, we can access this from either terminal on a Mac or Linux or from an SSH client, such as PuTTY on a Windows machine. We have covered the provisioning of an instance from the AWS Management Console, which is very comprehensive. But this is not the only way. Sometimes you'll want to perform these tasks via the AWS Command Line Interface, CLI, or using Windows PowerShell. You should become comfortable using the CLI as you will use this to perform more advanced actions, and these are a core skill you will need as part of the AWS certification. In addition to using the AWS Management Console, CLI, or Windows PowerShell, there is also Cloud Formation that enables you to provision your environment from a JSON-formatted template file and also programmatic access is also possible using the AWS SDKs that exist for most modern programming languages.

Now that your instance is running and you have full control, you need to ensure that you can properly manage the environment. Either you or a CIS admin must be familiar with backing up, securing, and patching the system to name a few administrative tasks that need to be carried out regularly. At this point, the logical question would be, "When wouldn't I use EC2?" This is a good question. And some scenarios might include your application has a requirement to access such features as a physical USB or serial dongle for licensing purposes where you need direct physical access to the system, you need to run Unix, non-x86 architecture, or legacy and non-supported operating systems, applications that can only work using multicast or via manipulating a layer to networking interfaces, for example, Microsoft network load balancing, applications that require same physical disks being attached to multiple different virtual machines, for example, Oracle Rac. You don't have the system administrative skills or don't want to do them, and this also includes investing time to understand how to take advantage of EC2 architectures, to make them highly available and scalable. The other reason that I often hear is that the instances can't handle the workload. For example, they can't vertically scale to what is required. This is an advanced discussion but there are a number of things that can be done to overcome these limitations and the vast majority of applications in the last 10 to 15 years will work fine. Pricing is an important aspect that you need to understand. And as we previously mentioned, if you're new to AWS, you're eligible for the free tier, which gives you access to EC2 resources. EC2 pricing is based on a per instance hour consumed for each instance, and this starts from the time an instance is launched until it is terminated or stopped, with each partial instance hour consumed being billed as a full hour. There are different pricing schemes based on the type and size of the instance. The types of instances are: on-demand. These instances allow you to pay for computing capacity by the hour with no long-term commitments. Reserved instances. These instances allow you to reserve EC2 computing capacity for one or three years, and in exchange for this commitment, you can realize discounted hourly rates up to 75% compared to on-demand instance pricing. Spot instances. This is spare EC2 instances for which you can bid for compute resources despite prices set by AWS, which fluctuates in real time based on supply and demand. And when your bid price is higher, the instances are launched until the price exceeds your current bid where you terminate the instance. This type of instance is ideal for tasks that can support interruption and often used for big data or analytical type applications. Dedicated instances. If you wish to take advantage of dedicated instances, there is a charge per instance, as well as a per region instance charge. To become familiar with the costing model, you can use the AWS pricing calculator, and for EC2 the minimum values you need are your instance type, storage and data transfer volumes. Amazon Elastic Compute Cloud is an important service that offers many benefits, and this introduction has only scratched the surface of its capabilities. To get a better understanding, it is highly recommended you undertake the intermediate and advanced compute courses offered by Cloud Academy.

About the Author
Learning Paths

David's acknowledged hands on experience in the IT industry has seen him speak at international conferences, operate in presales environments and conduct actual design and delivery services.

David also has extensive experience in delivery operations. David has worked in the financial, mining, state government, federal government and public sectors across Asia Pacific and the US