Amazon Elastic Compute Cloud (EC2) is the web service you use to create and run virtual machines in the cloud. Amazon Web Services calls these virtual machines 'instances'. This step-by-step guide will help you successfully launch a Linux virtual machine on Amazon EC2.
a. Click here to open the Amazon EC2 console and then click Launch Instance to create and configure your virtual machine.
You are now in the Amazon EC2 Launch Instance Wizard, which will help you configure and launch your instance.
a. In this screen, you are shown options to choose an Amazon Machine Image (AMI). AMIs are preconfigured server templates you can use to launch an instance. Each AMI includes an operating system, and can also include applications and application servers.
For this tutorial, find Amazon Linux AMI and click Select.
b. You will now choose an instance type. Instance types comprise of varying combinations of CPU, memory, storage, and networking capacity so you can choose the appropriate mix for your applications. For more information, see Amazon EC2 Instance Types.
The default option of t2.micro should already be checked. This instance type offers enough compute capacity to tackle simple workloads. Click Review and Launch at the bottom of the page.
c. You can review the configuration, storage, tagging, and security settings that have been selected for your instance. While you have the option to customize these settings, we recommend accepting the default values for this tutorial.
Click Launch at the bottom of the page.
d. On the next screen you will be asked to choose an existing key pair or create a new key pair. A key pair is used to securely access your Linux instance using SSH. Amazon Web Services stores the public part of the key pair which is just like a house lock. You download and use the private part of the key pair which is just like a house key.
Select Create a new key pair and give it the name MyKeyPair. Next click the Download Key Pair button.
After you download the MyKeyPair key, you will want to store your key in a secure location. If you lose your key, you won't be able to access your instance. If someone else gets access to your key, they will be able to access your instance.
Select your operating system below to see instructions on where to save your SSH key.
After you have stored your key pair, click Launch Instance to start your Linux instance.
e. Click View Instances on the next screen to view your instances and see the status of the instance you have just started.
f. In a few minutes, the Instance State column on your instance will change to "running" and a Public IP address will be shown. You can refresh these Instance State columns by pressing the refresh button on the right just above the table. Copy the Public IP address of your Amazon Web Services instance, so you can use it when we connect to the instance using SSH in Step 3.
After launching your instance, it's time to connect to it using SSH.
Windows users: Select Windows below to see instructions for installing Git Bash which includes SSH.
Mac/Linux user: Select Mac / Linux below to see instructions for opening a terminal window.
You can easily terminate the instance from the Amazon EC2 console. In fact, it is a best practice to terminate instances you are no longer using so you don’t keep getting charged for them.
a. Back on the Amazon EC2 Console, select the box next to the instance you created. Then click the Actions button, navigate to Instance State, and click Terminate.
b. You will be asked to confirm your termination - select Yes, Terminate.
Note: This process can take several seconds to complete. Once your instance has been terminated, the Instance State will change to terminated on your Amazon EC2 Console.