How to launch AWS EC2 Instance
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure, 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.
AWS EC2 is a compute service provided by AWS. This service provides different types of instances. This service offers us to choose any AMI image and we can have any type of AMI.
Open AWS Management Console and click on EC2 from the compute services.
LAUNCHING AN INSTANCE:-
After Clicking on EC2 , you will get this window. The leftmost navigation panel offers you various things like instances , its types, templates, AMIs, EBS volumes.
Now click on Instances.
After clicking on Instances , you will get this window. We can clearly see that we haven’t launched any instance yet. This is basically a dashboard for all the instances. It will show the running , terminated , stopped instances for us.
Now Go to Launch Instance.
STEP 1. Choose an AMI (Amazon Machine Image)
According to AWS, An AMI is a template that contains the software configuration which includes operating system, application servers , applications etc. required to launch your instance. There are different AMIs i.e. Linux server, windows server , macos server etc.
STEP 2. Choose Amazon Linux 2 AMI(HVM)
X86 is a intel CPU architecture. I am choosing 64 bit processor,
STEP 3. Choose an Instance type.
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.
T2.micro is available for free in free tier AWS account. T2.micro contains 1 vCPu , I Gib(1024^3 bytes) memory.
Step 4. After selecting t2.micro , click on Next: Configure Instance Details , you will get to choose to configure Instance Details.
If you are launching the instance first time or a beginner , leave all the values to default.
This step can change many features of the instance like changing number of instances to launch , Assigning subnets , VPC, CPU options and many more.
Click on Next: Add Storage at the right bottom.
Step 5. Add storage to the Instance.
A free tier account customers can get up to 30 GB of EBS SSD or Magnetic Storage.
Step 6. Click on Next: Add Tags.
Amazon Web Services allows customers to assign metadata to their AWS resources in the form of tags. Each tag is a simple label consisting of a customer-defined key and an optional value that can make it easier to manage, search for, and filter resources by purpose, owner, environment, or other criteria. AWS tags can be used for many purposes.
Step 7. Configure Security Groups .
Configuring security group gives us two options either we want to make a new security group or we want to select an existing security group.
A security group acts as a virtual firewall for your EC2 instances to control incoming and outgoing traffic. Inbound rules control the incoming traffic to your instance, and outbound rules control the outgoing traffic from your instance.
You can add as much as rules you want.
Step 8. Click on Review and Launch
Step 9. Launch. Then choose key pair.
I am creating a new key pair for my instance. Give the name to your keypair. When it’s done , you can download the key pair and then click on launch instances. The keypair will start downloading on your local system.
You can see the launch status here. You can also go to the dashboard of EC2 instances again and can check whether it starts running or not. When you will go to that dashboard , it will take 2-3 minutes to its state to running state. Only connect you rinstance when the status checks are 2/2 as they are required as they check the health of processors, and all the hardware.
CONNECTING EC2 INSTANCE :-
METHOD 1.
There are many ways to connect an EC2 instance. I am going to use Puttygen and Puttyconfiguration to connect my EC2 Instance.
Download Putty from here: - https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
Download Puttygen from here (64bit Windows): - https://puttygen.com/download.php?val=4
Putty is an open-source software which is a SSH and Telnet Client. SSH is basically a secure shell which is cryptographic network protocol for operating network services securely over an unsecured network.
Step 1: Select your instance and press on connect button.
Open your Puttygen from your local computer.
Puttygen is a key generator. We have to convert our download .pem file to .ppk file.
Click on load button and load your key pair which you have downloaded from your aws instance panel while launching the instance.
METHOD 2.
Select your instance and click on connect button.
The following window will appear :-
Go to SSH client to start your instance from Command line of your local system.
Go to your command prompt:
(i) Locate your key pair, I have downloaded it in my Downloads section so I changed the directory by using cd command.
cd Downloads
(ii) Connecting my instance using Public DNS. You can copy the command from your ssh client window from EC2 instance.
ssh -i "aws_instance.pem" [email protected]
To install APACHE Web server:
sudo yum -y install httpd
sudo service httpd start
After connecting by any method , when your work is over with ec2 instance , then stop the instance if you don’t want to get charge for it.
Click on Stop Instance and your instance will be stopped.