DEV Community

Kalpit Rathore
Kalpit Rathore

Posted on

AWS EC2: Launching an Amazon EC2 instance

Alt Text

In this post, We are going to create a Linux virtual machine hosted on the cloud (also known as Instance) using Amazon EC2. Amazon Elastic Compute Cloud (Amazon EC2) is an IaaS (Infrastructure as a Service) that provides secure, resizable compute capacity in the cloud.

To launch an EC2 Instance

  1. Sign in to the Amazon Management Console.

  2. From the navigation bar, choose a suitable geographic region that meets your requirements.
    Tip: Choose a nearer geographic region from your location to get faster responses

  3. Choose EC2 inside the Compute section of All services, It will redirects you to the Amazon EC2 Console

  4. From the EC2 dashboard choose Launch Instance

  5. Choose an Amazon Machine Image (AMI)
    Select an appropriate Amazon Machine Image(AMI). An AMI is a template that contains the software configuration (operating system, application server, and applications) required to launch your instance
    Tip: Choose Ubuntu if you are not familiar with other machine images
    Alt Text

  6. Choose an Instance Type
    Choose a suitable Instance type as per your needs. An Instance type describes the hardware specifications of the virtual machine (i.e. CPU, memory, storage, and networking capacity) and then click next.
    Tip: Choose t2.micro, Because it is the only instance type which is eligible for free tier
    Alt Text

  7. Configure Instance Details
    In this step, We can configure our instance i.e Network type, IP allocation, Monitoring, IAM role, etc. If you don't have any prior knowledge of cloud computing then I would recommend you to not change any setting and simply click next.
    Alt Text

  8. Add Storage
    An Amazon EBS Volume is similar as physical hard drive. In order to store data, We need to attach EBS volume to an instance. You can attach any size of disk space as per your needs. Free tier eligible customers can get up to 30 GB of EBS. We are choosing 25 GB disk space with General Purpose SSD (GP2) instance type. 
    Enable "delete on termination" checkbox. It will delete the disk space associated with the server, whenever the server will terminate.
    Alt Text

  9. Add Tags
    A tag is a key-value pair that you assign to an instance to uniquely identify them from a group. It doesn't alter instance's functionality. Click on add tag button, Enter "Name" in key field and "myserver" in value field. then click next.
    Alt Text

  10. Configure Security Group
    A security group controls inbound and outbound traffic from the server. There are set of protocol by which we can access the instance server i.e. HTTP, HTTPS, SSH. 

    • Click on Create a new security group in assign a security group section. 
    • Enter a security group name and description.
    • Now you need to define some protocol by which you are going to access the server. SSH protocol is added automatically, so you don't need to add it manually. Choose anywhere in source drop-down box of SSH protocol. This makes your server accessible from anywhere. Alternatively, You can bound the server with custom IP address as well.
    • Now click review and launch. Alt Text
  11. Review Instance Launch
    Review your instance launch details. You can go back to edit changes for each section. If all details are correct then you can click on launch.

    • It will ask you to select an existing key pair or create new key pair. A key pair, consisting of a private key and a public key which is used to access instance server securely. Creating a new security group for individual server is the best practice. 
    • Enter key pair name and click on Download Key Pair button, Once you are done downloading, Save this key in a secure folder and then click on Launch Instance button. Note:- If you lost your key pairs, then you will not able to download it again. Alt Text Alt Text
  12. It takes 2–3 minutes to create an instance, Now click on the instance button in the left panel. It will redirect you to the page where you can see list of instances created by you.
    Alt Text
    Alt Text

  13. Wait until the instance state of "myserver" is changed from pending to running.
    Alt Text

  14. We have successfully created an instance server. Now, We need to access it using SSH. Click on instance go to details tab, there we can see Public IP, Just copy it.
    Alt Text

  15. Open Terminal or Command Prompt, Go to the folder where you store the key pair file and type the command
    ssh -i key-pair.pem ubuntu@public_ip
    replace "key-pair.pem" with your key-pair file name and public_ip with your instance's public ip.
    Alt Text

  16. It will ask you to add server's fingerprint, then simply type yes and press enter 
    Alt Text

  17. Type

sudo su -
sudo apt-get update
Enter fullscreen mode Exit fullscreen mode

Alt Text

So we have successfully created and accessed an instance server. With the help of ec2 instance we can build web server, database server, vpn server, game server, data analysis server, geolocation or map server and lot more.

We'll going to build or experiement all of this with our EC2 Server.

For more update, Follow me on twitter or instagram

Top comments (0)