1. EC2 instancesΒΆ

Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services (AWS) cloud. This service allows you to configure and rent computers to meet your compute needs on an as needed basis. Using EC2 eliminates the need to invest in hardware up-front. EC2 can be used to launch as many or as few virtual servers needed, configure security and networking, and manage storage. Amazon EC2 enables scaling up or down to handle changes in requirements or spikes in popularity, reducing the need to forecast traffic.

Instance come in various shapes and sizes. Some instances might be geared towards running CPU intensive tasks while other might be optmized for memory or storage. Some of the different options available are shown in the figure below and more information can be found here.

../../_images/ec2_instances.png

The following sections outline the various steps involved in setting up an EC2 instance:

  1. AMI selection

An Amazon Machine Instance (AMI) is a preconfigured template for launching an instance. It packages the various applications you need for your server (including the operating system and additional software). There are four main options when selecting an AMI: Quick Start, My AMIs, AWS Marketplace and Community AMIs. These options can be seen in the image below on the left sidebar. Select the desired AMI and then proceed to the next step.

../../_images/instance_launch.png
  1. Instance type selection

Once an AMI is selected, the next step is to choose an instance type. If choosing an AMI is equivalent to choosing the software you want on your computer then choosing an instance type is equivalent to choosing the hardware. Broadly speaking the different instance types vary in the number of CPUs, or size of RAM, or storage. The price per hour for each of the options is not listed here. To get the price of a particular instance, look up the name of the instance on the EC2 pricing list. Once you are ready, proceed to the next step by pressing the Next: Configure Instance Details button.

../../_images/instance_types.png
  1. Instance general configuration

Once you have selected your instance type, the next step is to configure your instance. This step involves many advanced concepts that will be not be covered in detail in this tutorial. Using the Number of instances option you can launch multiple instances with the same AMI and hardware configuration at the same time. Additionally you could also Request Spot instances (spot instances offer spare compute capacity at steep discounts but they are reclaimed whenever EC2 needs the capacity back) Shutdown behavior determines the behavior of the instance when it is shutdown from within the AMI

For this tutorial we will use the proceed with the default values for all the options.

../../_images/instance_configure.png
  1. Instance storage configuration

The next step is to configure the storage that will be available to the instance. The storage that you start with depends on the type of instance you have selected. In the image below we have an EBS root volumne with 8GiB size. This is the Root volume where the operating system will exist By default, this volume is set to be deleted when the instance is terminated, but, this behavior can be changed. The Add New Volume button can be used to add additional storage to our instance.

  • ephemeral or Instance store storage
  • EBS storage
../../_images/instance_storage.png
  1. Instance tagging

When dealing with multiple instances, tagging creates a simpler way to track usage and billing information from groups of related instances

../../_images/instance_tags.png
  1. Instance security

Secure login information for instances using key pairs (AWS stores the public key, and the user stores the private key in a secure place) A firewall that enables you to specify the protocols, ports, and source IP ranges that can reach your instances using security groups

../../_images/instance_security.png
  1. Instance review

Static IPv4 addresses for dynamic cloud computing, known as Elastic IP addresses

../../_images/instance_review.png

Created instance

../../_images/instance_created.png

Create a key and save it

../../_images/instance_key.png

Key file example. The file can be saved as Test.pem

-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAhEpF18lIUouMH8qia/BSB70vrQVq/mTTkiRbsACB78rzy3XGRMfvwUseIsGY
H6SDOAFrRlmTrAArH5A0t2TZ8PKrq7b9FtEAvMCeE7rWEiqBblAWiER0k1pbnIqyKJJCo1YRSUs0
oNMdvjB4CUylYraSsSNFYJG5gRwcNhBENLDVnDS79geQcPLu/JeEiJ9V+w+CCYAG40f7li/TuULr
rSy6Oq6jgn2Gy7rrHU7XHU5hcEvxuSeoLb8h/bH1N+cN/H7x3ipEjIDdA2ScCkRXum1V6/kTFQFq
vDG0lqoTlmTNKgDGpb+rdzJgOg/3QX4RSrX/c0W6aFkV9Ib/jQxT+wIDAQABAoIBADAvWXc6wpQG
bjiaN0T3mPlmqHnuEkWs9f8yLQ9TcACmvNwr/tbIuISAVu6z8zP7WSxKIAfU0twAh7SMcxclrdh8
m5kFIvRvlkQqKKnpENY3E0PZ+gsSXB/b9qhzQGdUtt8Fl3BJ61Z07016HA7PEyJ8e7v3q+p7ycTE
N2Zd0GocRIX8zxdRo9GS8ouS0QcFgNF8KblzlJ6Vs0gI7o7mIRZIm9vWkuR9Lp9uEPD2flUIvN3z
yRmY/FE/R1yc76Uq+g8eywifRAh+GFyyO8PmFoYRni4Ki6+tEIFaq5JauT0JJF66EZeZP8ZKoWm9
1K30Ucti2D5l8t+C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