How to create Amazon EC2 instance
Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services (AWS) cloud. It is a web service where an AWS subscriber can request and provision a compute server in AWS cloud.
The instance will be charged per hour with different rates based on the type of the instance chosen. AWS provides multiple instance types for the respective business needs of the user.
Creating Amazon EC2 instance is very simple. Amazon provides multiple ways to create/launch Amazon EC2 instance.
- Create Amaozn EC2 instance through Amazon Management Console
- Create Amazon EC2 instance through Amazon Cloud formation template
- Create Amazon EC2 instance through Amazon CLI
Create Amaozn EC2 instance through Amazon Management Console
Following are 8 steps to create Amaozn EC2 instance through Amazon Management Console.
- Login and access to AWS services
- Choose AMI
- Choose Instance Types
- Configure Instance
- Add Storage
- Tag Instance
- Configuring Security Groups
- Review Instances
1. Login and access to AWS services
1.1 Login to your AWS account (login link)
1.2 Click on Services link on top left corner.
1.3 Go to Compute and Click on EC2 link.
1.4 On the top right corner of the EC2 dashboard, choose the AWS Region in which you want to provision the EC2 server.
1.5 Click on Instances link on link in the left verticle.
1.6 Click on
Launch Instance button.
2. Choose AMI
After clicking on
Launch Instance, you need to choose AMI. (What is Amazon Machine Image?)
Here we are choosing the default Amazon Linux (64 bit) AMI, which is eligible for Free tier.
Select button in front of AMI.
Note: Be very careful while selecting AMI. There are many AMIs which contains paid softwares. So for safer side select only Free tier AMI.
3. Choose Instance Types
In the next step, you have to choose the instance type based on your business requirement.
In this example I am going to choose t2.micro instance type, which have 1vCPU and 1GB memory server offered by AWS.
Configure Instance Details button, for further configuration.
4. Configure Instance
Following basic configuration are mandatory for launching EC2 instance.
- Number of instances: You can launch up to 20 instances at a time, here I am going to launch 1 instance.
- Purchasing option: In this example, I am going to keep unchecked Request Spot Instances.
- Network: In this example, I am going to choose default VPC which is provided by AWS.
Instead of default VPC you can choose your own choice VPC, but first you have to create VPC then use it.
- Subnet: In this example, I am going to choose “No prefrence (default subnet in any Availability Zone)”
- Auto-assign Public IP: For this example, I’m using Enable
- IAM role: Select None
- Shutdown behavior: For this example, I’m using Stop
- Enable termination protection: For this example, I’m keeping this option unchecked, howevery for production enviornment it must be checked.
- Monitoring: This is chargable servive, so keeping this option unchecked.
- Tenancy: For this example, I’m using “Shared – Run a shared hardware instance”
- T2 Unlimited: For this example, I’m using unchecked.
Now click on
"Next: Add Storage" button.
5. Add Storage
Following are the steps to add storage to your EC2 instance.
- In the Add Storage step, you’ll see that the instance has been automatically provisioned a General Purpose SSD root volume of 8GB. ( Maximum volume size we can give to a General Purpose volume is 16GB)
- You can change your volume size, add new volumes, change the volume type, etc.
- AWS provides 3 types of EBS volumes- Magnetic, General Purpose SSD, Provisioned IOPs. You can choose a volume type based on your application’s IOPs needs.
6. Tag Instance
You can tag your instance with mutiple key-value pair.
- Tagging gives visibility to the AWS account administrator when there are lot number of instances.
- The instances should be tagged based on their department, environment like Dev/SIT/Prod. Etc. this gives a clear view of the costing on the instances under one common tag.
"Add Tag" button, the provide Key and Value.
Now click on
"Next: Configure Security Group" button to configure security.
7. Configuring Security Groups
In this step of configuring Security Groups, you can restrict traffic on your instance ports. This is an added firewall mechanism provided by AWS apart from your instance’s OS firewall.
You can define open ports and IPs.
Since our server is a webserver, we will do following things
- Creating a new Security Group
- Naming our SG for easier reference
- Defining protocols which we want enabled on my instance
- Assigning IPs which are allowed to access our instance on the said protocols
Note: Never ever enable SSH protocode to the world that is 0.0.0.0/0. It has major security issue. Always try to enable your network or company subnet for SSH protocol.
Once, the firewall rules are set, click on
"Review and launch" button.
8. Review Instances
- In this step, we will review all our choices and parameters and go ahead to launch our instance.
- In the next step you will be asked to create a key pair to login to you an instance. A key pair is a set of public-private keys.
AWS stores the private key in the instance, and you are asked to download the public key. Make sure you download the key and keep it safe and secured; if it is lost you cannot download it again.
You can use existing key-pair or create a new key-pair. Following are the steps to create a new key-pair:
- Create a new key pair
- Give a name to your key
- Download and save it in your secured folder
After you download the key-pair. Click on
"Launch Instance" button.
Amazon will start launching your instance, and status will be shown on “Launch Status” page.
Now Click on instance Id to check your instance details.
To check instance is healthy and working fine, see “Status Checks” of the instance should be 2/2 checks
Post EC2 instance actions
After your EC2 instance launched successfully, you would like to access/login to your instance from local machine and install required softwares.
Following are the links which will help you to to perform certain useful operation post EC2 instance launch.
- Connect to your EC2 instance from Windows machine
- Connect to your EC2 instance from Linux/Mac machine
- Attach a Elastic IP to Amazon EC2 instance
- Attach a EBS volumn to Amazon EC2 instance
6,635 total views, 3 views today