cft

How to Launch an EC2 Instance on AWS

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers.


user

Oluwashola Umakhihe

a year ago | 5 min read

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers.

Amazon EC2’s simple web service interface allows you to obtain and configure capacity with minimal friction. It provides you with complete control of your computing resources and lets you run on Amazon’s proven computing environment. Amazon EC2 reduces the time required to obtain and boot new server instances to minutes, allowing you to quickly scale capacity, both up and down, as your computing requirements change.

Amazon EC2 changes the economics of computing by allowing you to pay only for the capacity that you actually use. Amazon EC2 provides developers the tools to build failure resilient applications and isolate themselves from common failure scenarios.


  1. Open You AWS Management Console

2. Go to www.console.aws.amazon.com, login to your account, and your management console will open

3. In the AWS Management Console on the Services menu, click EC2.

4. Click Launch Instance

5. Choose an Amazon Machine Image (AMI)

An Amazon Machine Image (AMI) provides the information required to launch an instance, which is a virtual server in the cloud. An AMI includes:

  • A template for the root volume for the instance (for example, an operating system or an application server with applications)
  • Launch permissions that control which AWS accounts can use the AMI to launch instances
  • A block device mapping that specifies the volumes to attach to the instance when it is launched

6. Click Select next to Amazon Linux 2 AMI (at the top of the list).

7. Choose an Instance Type

Amazon EC2 provides a wide selection of instance types optimized to fit different use cases. Instance types comprise varying combinations of CPU, memory, storage, and networking capacity and give you the flexibility to choose the appropriate mix of resources for your applications. Each instance type includes one or more instance sizes, allowing you to scale your resources to the requirements of your target workload.

You will use a t2.micro instance which should be selected by default. This instance type has 1 virtual CPU and 1 GiB of memory. NOTE: You may be restricted from using other instance types in this lab.

8. Click Next: Configure Instance Details

9. Choose an Instance Type

Amazon EC2 provides a wide selection of instance types optimized to fit different use cases. Instance types comprise varying combinations of CPU, memory, storage, and networking capacity and give you the flexibility to choose the appropriate mix of resources for your applications. Each instance type includes one or more instance sizes, allowing you to scale your resources to the requirements of your target workload.

You will use a t3.micro instance which should be selected by default. This instance type has 1 virtual CPU and 1 GiB of memory. NOTE: You may be restricted from using other instance types in this lab.

10. Click Next: Configure Instance Details

11. Configure Instance Details

This page is used to configure the instance to suit your requirements. This includes networking and monitoring settings.

The Network indicates which Virtual Private Cloud (VPC) you wish to launch the instance into. You can have multiple networks, such as different ones for development, testing and production.

For Network, select The Default VPC or Create your own VPC

For Enable termination protection, select Protect against accidental termination.
When an Amazon EC2 instance is no longer required, it can be terminated, which means that the instance is stopped and its resources are released. A terminated instance cannot be started again. If you want to prevent the instance from being accidentally terminated, you can enable termination protection for the instance, which prevents it from being terminated.

Scroll down, then expand Advanced Details.
A field for User data will appear.
When you launch an instance, you can pass user data to the instance that can be used to perform common automated configuration tasks and even run scripts after the instance starts.
Your instance is running Amazon Linux, so you will provide a shell script that will run when the instance starts.

Copy the following commands and paste them into the User data field:

#!/bin/bash
yum -y install httpd
systemctl enable httpd
systemctl start httpd
echo ‘<html><h1>Hello From Your Web Server!</h1></html>’ > /var/www/html/index.html
  • Install an Apache web server (httpd)
  • Configure the web server to automatically start on boot
  • Activate the Web server
  • Create a simple web page

Click Next: Add Storage

Add Storage

Amazon EC2 stores data on a network-attached virtual disk called Elastic Block Store.

You will launch the Amazon EC2 instance using a default 8 GiB disk volume. This will be your root volume (also known as a ‘boot’ volume).

Click Next: Add Tags

Add Tags

Tags enable you to categorize your AWS resources in different ways, for example, by purpose, owner, or environment. This is useful when you have many resources of the same type — you can quickly identify a specific resource based on the tags you have assigned to it. Each tag consists of a Key and a Value, both of which you define.

Click Add Tag then configure

Click Next: Configure Security Group

Configure Security Group

A security group acts as a virtual firewall that controls the traffic for one or more instances. When you launch an instance, you associate one or more security groups with the instance. You add rules to each security group that allow traffic to or from its associated instances. You can modify the rules for a security group at any time; the new rules are automatically applied to all instances that are associated with the security group.

On Step 6: Configure Security Group, configure

Click Review and Launch

Review Instance Launch

The Review page displays the configuration for the instance you are about to launch.

Click Launch
A Select an existing key pair or create a new key pair window will appear.
Amazon EC2 uses public–key cryptography to encrypt and decrypt login information. To log in to your instance, you must create a key pair, specify the name of the key pair when you launch the instance, and provide the private key when you connect to the instance.

Click Launch Instances
Your instance will now be launched.

Click View Instances
The instance will appear in a pending state, which means it is being launched. It will then change to running, which indicates that the instance has started booting. There will be a short time before you can access the instance.
The instance receives a public DNS name that you can use to contact the instance from the Internet.
Your Web Server should be selected. The Description tab displays detailed information about your instance.
To view more information in the Description tab, drag the window divider upwards.
Review the information displayed in the Description tab. It includes information about the instance type, security settings and network settings.

Wait for your instance to display the following:

  • Instance State: running
  • Status Checks: 2/2 checks passed

Congratulations! You have successfully launched your first Amazon EC2 instance.



Upvote


user
Created by

Oluwashola Umakhihe

Freelancer

Front end developer | AWS cloud practitioner | Wordpress | Technical Writing | Python Enthusiast | Digital Marketing


people
Post

Upvote

Downvote

Comment

Bookmark

Share


Related Articles