How to Create and Configure Amazon EC2 Instance
Using Amazon EC2 eliminates the need to invest in hardware up front so that you can develop and deploy applications faster.
You may use Amazon EC2 to establish as many or as few virtual servers as you need, configure media and security, and manage storage.
The instance will be billed per hour with various rates based on the kind of the instance chosen. AWS provides multiple case types for your respective business needs of the consumer.
Amazon EC2 allows you to scale down or up to manage changes in requirements or spikes in popularity, lowering your need to forecast traffic.
Features of Amazon EC2:
Amazon EC2 provides the following features:
- AWS contains per defined instance templates known as AMI (Amazon Machine Image). These instances can be configured as per requirement to launch as the virtual server.
- EC2 provides various configurations of CPU, memory, storage, and networking capacity for your instances, known as instance types.
- Secure login information for your instances using key pairs (AWS stores the public key, and you store the private key in a safe place)
- EC2 deletes the temporary storage volumes when you stop or terminates your instance, known as instance store volumes
- Multiple physical locations for your resources, such as instances and Amazon EBS volumes, known as regions and Availability Zones
- A firewall that enables you to specify the protocols, ports, and source IP ranges that can reach your instances using security groups
- Static IPv4 addresses for dynamic cloud computing, known as Elastic IP addresses
- Metadata, known as tags, that you can create and assign to your Amazon EC2 resources
Login to AWS console
- Log in to your AWS account. Click on the services on the top left corner to access the services.
- On the top right corner, you can see your current region, click on that to see all the region which you can select to launch your instance or any other service.
- Till September 2018, AWS providing 19 regions for different services. You can get more details on the regions and availability of service by visiting this link.
- I am choosing Mumbai, but you can select any region as per requirement.
For launching EC2 instance click on the EC2 option under the Compute.
Now you are in EC2 dashboard where you can see all the stats of your running or stopped EC2 resources.
For creating an instance click on the launch instance which will open the Instance creation wizard.
- AWS provides us with a wide range of Linux and Windows-based AMI (Amazon Machine Image). We can choose any AMI as per our requirement.
- You can see that some of these AMI comes in the free tier category. If you’re confused with the AMI than its nothing but the template of Operating system that you can use to create the instances.
- Here I am selecting Red Hat Enterprise Linux 7.5.
Choose Instance Type
- In this step, we have to select the type of instance we have install based on our requirement.
- Here we will choose t2.micro, which is a 1GB RAM and 1vCPU offered by the AWS.
Now click on Configure Instance Details for the further steps.
Configure Instance Details
- Number of Instances: In this option, you can choose the number of instances you want to install. You can select up to 20 cases at a time, but here we are selecting one instance.
- Purchasing Option: Keep the ” Request Spot Instances” option unchecked as of now. (You can read more about spot pricing on this link)
- Network: In this option, we have to select the VPC (Virtual Private Cloud) where we have to launch our instance. Here you can see a default VPC, but you can also create new VPC for your instances. Here we are going with the default VPC.
- Subnet: You can select any subnet in your VPC to launch the instance and also create a new one. Here, we are going with the existing default subnet.
- Auto-assign Public IP: Click on the drop-down menu and select Enable for auto-assigned dynamic IP. If you have your IP, you can choose the Disable and assigned the IP later. Here we are going with the enable
- Placement Group: As of now keep it uncheck as we don’t want to add the instance to Placement Group (Placement group determines how instances are placed on underlying hardware)
- IAM Role: Choose the default option “None” as of now. We will cover the IAM Role in upcoming tutorials.
- Shutdown Behaviour: This is an important option when you accidentally shut down your instance you don’t want the termination of your instance. Here we are selecting shutdown behaviour as Stop. Enable termination.
- Protection: AWS provides us with an extra layer of protection from accidental termination of Instance. If you enable the option, the instance will not be deleted in case of unintentional termination.
- Monitoring: You can enable this option for monitoring the instance status but its a paid service. By default, AWS provides the basic monitoring for free of cost. Here we are not enabling this feature.
- Tenancy: If you are running a highly secure application than choose the dedicated instance otherwise you can choose the “Run a shared hardware instance”.
- T2 Unlimited: This will provide us with the extra CPU power in case of over-consumption of resources, but it’s not a free service. the charges will be applied on the hourly basis
- Network Interface: If you have any other IP you can add that on Secondary IP column. AWS supports both IPv4 and IPv6 so you can add anyone of that.
In add storage option you can add storage dick to the instance. The minimum size you can add is 4 GB also you can add upto 30 GB General Purpose EBS if you are free tier user. Here I am adding 10 GB General Purpose storage.
- This option provides the facility of naming the instances if there are lots of instances are running.
- Click on add tag and add Key (For example departments like Development or operations) and Value (Like Dev1, Dev2, etc.)
- Here we are giving Name as key and GeeksradarVM as Value.
Now click on Configure Security Group for the next step.
- Assign a security Group: Here you have two options of choosing existing security group or add a new one
- Security Group Name: In case of new security group you can provide name, In our case its GeeksRadar.
- Description: You can add the description of the security group for the future reference, but we are living it untouched.
- Types: You can select the type of protocol which you want to enable for instance.
- Source: In the source column, you can restrict the access by putting any specific IP. We are setting the default value, i.e., 0.0.0.0, which means it can be accessed from anywhere (It is not recommended to put it on default value in the case of a sensitive application)
Now click on Review and Launch
Now click on Launch.
A popup tab will generate and ask for the keys pair which you will use for login into the instance. If you already have a key pair and you don’t want to create a new one then select “Choose an existing key pair” and “Create a new key pair for” creating a new pair.
Now put the name of the key pair as per your choice. We are putting Geeks as the key pair name. Click on “Download Key Pair” for saving the key on the local machine.
Now We can log in to the server by using the key and any SSH clients like Putty, ZOC, etc Putty is one of the famous SSH clients but for using that we have to convert the key into PPK which can be quickly done by using Puttygen software which you can download from this link.
But If you feel that using putty is tough, then you can use ZOC which supports the PPM keys, so you don’t have to convert the key. In this tutorial, we are going with ZOC.
For login into the instance, first of go to the EC2 dashboard and copy the IP address of the instance. Start the ZOC, go to File > Quick Connection and paste the copied IP in the Connect to the tab. Set the port name 22 and put “ec2-user” in username tab(leave the password section blank as we are signing with SSH key). Now browse the SSH key which we had downloaded.