Ec2 Instance Setup

Kaushik G
4 min readFeb 26, 2024

--

EC2 is a cloud computing platform that provides on-demand, scalable computing capacity. It allows users to build and run applications faster, without needing to invest in hardware upfront. Here we bring forward the procedure to launch an EC2 instance.

Create an AWS account:

During signup, you’ll be asked for your billing information, but you won’t be charged unless you exceed the free tier limits. Be mindful of how you use resources, and terminate instances when you’re finished to avoid unintended charges.

Navigate to Services Menu:

This menu gives the view of all the services in AWS.

After the creation of the account reach out to the services menu and search for EC2.Then you’ll find a launch instance button, go ahead and click on it. Then launch an instance screen will appear.

EC2 Instance Launch Menu:

Instance Initialization

Feel free to choose any name you prefer; I’ve named it “pyspark” as we proceed with the PySpark setup.

Choosing AMI:

Choose Ubuntu Server as we’re using Free tier:

AMI availabilities

Choose the Instance Type:

With reference to the Memory you’d be needing for processing (Memory is used to hold data that the CPU is currently processing i.e. RAM in simpler terms). Here I’ve chosen t2.micro because that has free-tier on it; it will provide us with 1Gib Memory. Feel free to change as your need but that would incur charges be cautious.

Instance Type Selection

Key Pair Creation:

Proceeding, we need to create a key pair for login purposes. You may be wondering if you don’t know about key pairs. What is key pairs for?..

An Amazon EC2 key pair is a set of security credentials that proves your identity when connecting to an EC2 instance. It consists of a public key and a private key which can be used during login to ensure authenticity.

Create a key pair with the name you desire, ensure the private key file format is in .pem format. We can also use .ppk but it requires PuTTy for establishing connection, whereas .pem can be directly used on command prompts. However if you want to follow .ppk method I have attached the linked on how to establish connection using .pem files.

Key Pair Details

After you name the key pair click on create new key pair. It will redirect for a .pem file download store it in a folder as you wish. Here I’ve already created a key pair so I’ll proceed with the same.

Network Settings:

Under the network settings,

Security Group

Make sure you toggled on the Allow HTTPS & HTTP traffic from internet, this will ensure you can access the created Jupyter Notebook. It’s ok if you forget to toggle them you just have to edit the inbound & outbound rules after launching the instance. This won’t be much of a hazzle for you.

Launching the Instance:

And obviously, the instance will be created once you click on Launch Instance. It will carry the security groups we’ve created

Now we have successfully created a instance. To proceed with it,

Access the instance:

Go to the folder you saved the key pair which was downloaded. Open Command Prompt within the folder.

After you open the command prompt with the desired location, type the following code

ssh -i sparksetup.pem ubuntu@ec2–44–206–224–236.compute-1.amazonaws.com

Here,

ssh -i is standard; sparksetup.pem is the key pair i generated; ubuntu is the AMI which I created (if you were following me from the first it would be same for you). The later part is where it differs for everyone.

Go back to AWS services and look for the instances which are running. Choose them and you’ll find a Public IPv4 DNS like this ec2–44–206–224–236.compute-1.amazonaws.com copy that and complete the command and hit the ‘Enter’. The public IPv4 DNS differs over individual to individual.

You’ll get a welcome screen like this,

Virtual Machine

Now we have access over our virtual machine, We’ll install all our requirements in this which will all be virtual won’t require memory locally.

This is how an EC2 instance is launched with ssh/ .pem format key pair.

--

--

Kaushik G

My blog serves as a chronicle of insights and discoveries in fascinating fields with data. Join me in exploring the cutting edge, one blog post at a time!"