Create an EC2 Instance in AWS
In this tutorial, we are going to learn how to setup EC2 resources by choosing Amazon Machine Image (AMI), add storage, configure security groups, and create PEM key to access your instance using SSH.
Prerequisites
You need an Amazon Web Services Account.
Choose Amazon Machine Image(AMI)
- You need to AWS console and navigate to
Services -> EC2
.
Then Click on Instances
on the left sidebar.
After that click on Launch instance
.
Services -> EC2
.Then Click on Instances
on the left sidebar.
After that click on Launch instance
.
Then you will redirect to a page where you can choose any AMI according to your requirments but in this tutorial I am using Ubuntu server 18.04 image.
Choose Instance type
Here you can choose your desired machine type. In this tutorial I am using t2.micro
type instance.
Then click on Configure Instance Details
Configure Instance
Here you can choose how your instance should run as dedicated or as shared. But for now we leave all settings to be as default.
Then click on Add Storage
Add Storage
In this tutorial we leave this with the default settings.
Then click on Add Tags
Add Tags
Tags are useful to identify the Instance, here we will assign a name to our instance.
Click Add Tag
, then enterName
as the Key
& Test-EC2
as value
. You can any value according to your preference.
Click Configure Security Group
Configure Security Group
This is an important setup where you can allow connections to your instance by opening certain ports.
By default SSH port
is enabled.
If you need your website to be viewed in the internet then you need add rules to allow connections to
HTTP
andHTTPS
.Click
Add rule
.From the type select
HTTP
.Again click
Add rule
.From the type select
HTTPS
.
If you need any additional ports opened you can add rules for those ports also.
Click Review and Launch
.
Review the Instance details
In this section you can review all the options you have chosen in the steps before. Once you have reviewed them you can click launch.
Create PEM key and launch Instance
Now you will be prompted to assign a key pair to access your instance.
Select create a new key pair.
Enter a name to your key.
Click Download Key Pair.
Now you will be prompted to assign a key pair to access your instance.
Select create a new key pair.
Enter a name to your key.
Click Download Key Pair.
Important: Save the key pair, if you miss this key you wont be able to access your instance using SSH.
- Click Launch instances.
That’s all. Now your instances will be launched with Ubuntu 18.04 and will all the configurations you made.