Get Started With Amazon EC2 Linux Instances
Get Started With Amazon EC2 Linux Instances
Instances
Use this tutorial to get started with Amazon Elastic Compute Cloud (Amazon EC2). You'll learn
how to launch, connect to, and use an Amazon EC2 Linux instance. An instance is a virtual server
in the AWS Cloud. With Amazon EC2, you can set up and con gure the operating system and
applications that run on your instance.
In this hands-on, you will launch an instance using de ned parameters.You can accept any or all
of the defaults, or con gure an instance by specifying your own values for each parameter. The
parameters are grouped in the launch instance wizard. The following instructions take you through
each parameter group.
Page 1 of 11
fi
fi
fi
fi
fi
2. In the navigation bar at the top of the screen, the current AWS Region is displayed (for
example, US East (N.Virginia)). Select a Region in which to launch the instance. This choice
is important because some Amazon EC2 resources can be shared between Regions, while
others can’t.
Page 2 of 11
Name and tags
The instance name is a tag, where the key is Name, and the value is the name that you specify.
You can tag the instance, the volumes, and elastic graphics. For Spot Instances, you can tag the
Spot Instance request only.
• For Name, enter a descriptive name for the instance. If you don't specify a name, the
instance can be identi ed by its ID, which is automatically generated when you launch the
instance.
• To add additional tags, choose Add additional tags. Choose Add tag, and then enter a key
and value, and select the resource type to tag. Choose Add tag again for each additional
tag to add.
5. Under Application and OS Images (Amazon Machine Image), choose Quick Start, and then
choose the Amazon Linux 2 AMI (HVM) - Kernel 5.10, SSD Volume Type for your instance.
Page 3 of 11
fi
Instance type
The instance type de nes the hardware con guration and size of the instance. Larger instance
types have more CPU and memory.
6. For Instance type, select the instance type for the instance.
If your AWS account is less than 12 months old, you can use Amazon EC2 under the Free Tier by
selecting the t2.micro instance type (or the t3.micro instance type in Regions where t2.micro is
unavailable).
Compare instance types: You can compare di erent instance types by the following attributes:
number of vCPUs, architecture, amount of memory (GiB), amount of storage (GB), storage type,
and network performance.
• For Name, enter a descriptive name for the key pair. Amazon EC2 associates the public key
with the name that you specify as the key name. A key name can include up to 255 ASCII
characters. It can’t include leading or trailing space
Page 4 of 11
fi
fi
fi
ff
• Choose Create key pair.
• The private key le is automatically downloaded by your browser. The base le name is the
name that you speci ed as the name of your key pair, and the le name extension is
determined by the le format that you chose. Save the private key le in a safe place.
Network settings
8. Con gure the networking settings as following:
• Network: Here the default VPC is selected automatically. You will be launching this EC2
instance in the same default VPC of the region you’re working in.
• Subnet: You can launch an instance in a subnet associated with an Availability Zone, Local
Zone, Wavelength Zone, or Outpost. For this hands-on, keep Subnet to No preference
(Default subnet in any availability zone).
Page 5 of 11
fi
fi
fi
fi
fi
fi
fi
• Auto-assign Public IP: Specify whether your instance receives a public IPv4 address. By
default, instances in a default subnet receive a public IPv4 address, and instances in a non-
default subnet don't. You can select Enable or Disable to override the subnet's default setting.
For this hands-on, keep Auto-assign public IP to Enable.
9. The launch instance wizard automatically de nes the launch-wizard-x security group and
creates an inbound rule to allow you to connect to your instance over SSH (port 22). Include the
inbound rules as following:
• To let the launch instance wizard add your computer's public IP address, choose My IP.
However, if you are connecting through an ISP or from behind your rewall without a static IP
address, you need to nd out the range of IP addresses used by client computers.
• Select Allow HTTPs tra c from the internet and Allow HTTP tra c from the internet rules
to allow internet tra c.
Page 6 of 11
fi
ffi
fi
ffi
fi
ffi
fi
Advanced Details
11. For Advanced details, expand the section to view the elds and specify any additional
parameters for the instance.
• Accept all default parameters here except for User data. You can specify user data to con gure
an instance during launch, or to run a con guration script.
• Click here to download the bash script which will be used launch an Apache PHP web
application on this EC2 instance.
• Copy and paste the contents of the download script within User data eld.
Page 7 of 11
fi
fi
fi
fi
Summary
12. Use the Summary panel to specify the number of instances to launch, to review your instance
con guration, and to launch your instances.
Page 8 of 11
fi
14. You will be straightaway sent to the Instances dashboard. Select the launched instance and
look for Public IPv4 address and Public IPv4 DNS within Details.
15. Now, access the website using either the public IPv4 address or public IPv4 DNS name and
you should get the following output.
Page 9 of 11
Terminate your instance
You can delete your instance when you no longer need it. This is referred to as terminating your
instance. As soon as the state of an instance changes to shutting-down or terminated, you
stop incurring charges for that instance.
16. Select the instance, and choose Instance state, Terminate instance.
Page 10 of 11
fi
After you terminate an instance, it remains visible in the console for a short while, and then the
entry is automatically deleted. You cannot delete the terminated instance entry yourself. After an
instance is terminated, resources such as tags and volumes are gradually disassociated from the
instance and may no longer be visible on the terminated instance after a short while
When an instance terminates, the data on any instance store volumes associated with that
instance is deleted.
Summary
This completes the hands-on exercise on launching of an Amazon EC2 Linux instance. You also
used a bootstrap script to install an Apache web server on it and later tested the website
successfully. After testing, the instance was terminated to clean up and avoid any unexpected
charges.
Page 11 of 11