I am going to use the following reference link for this article:
Amazon Elastic Compute Cloud (EC2) is the Amazon Web Service
you use to create and run virtual machines in the cloud. AWS calls these
virtual machines 'instances'. Note, I am going to use Free tier account from AWS for this article.
Step 1: Login to your Amazon aws account. From “All
services”, select EC2 to launch EC2 Dashboard. Click Launch Instance to create
and configure your virtual machine.
Step 2: Configure your Instance
choose an Amazon Machine Image (AMI). AMIs are preconfigured
server templates you can use to launch an instance. Each AMI includes an
operating system, and can also include applications and application servers.
You will now choose an instance type. Instance types
comprise of varying combinations of CPU, memory, storage, and networking capacity
so you can choose the appropriate mix for your applications. The default option
of t2.micro should already be checked.
This instance type is covered within the Free Tier and offers enough
compute capacity to tackle simple workloads. Click Review and Launch at the
bottom of the page.
Click Launch
- On the next screen you will be asked to choose an existing key pair or create a new key pair. A key pair is used to securely access your Linux instance using SSH. AWS stores the public part of the key pair which is just like a house lock. You download and use the private part of the key pair which is just like a house key.
- Select Create a new key pair and give it the name MyKeyPair. Next click the Download Key Pair button.
- After you download the MyKeyPair key, you will want to store your key in a secure location. If you lose your key, you won't be able to access your instance. If someone else gets access to your key, they will be able to access your instance.
For Windows:
- We recommend saving your key pair in your user directory in a sub-directory called .ssh (ex. C:\user\{yourusername}\.ssh\MyKeyPair.pem).
NOTE: Create your ssh directory name like (.ssh.), the final
period is removed automatically.
After you have stored your key pair, click Launch Instance
to start your instance.
Click View Instances on the next screen to view your
instances and see the status of the instance you have just started.
- In a few minutes, the Instance State column on your instance will change to "running" and a IPv4 Public IP address will be shown. Copy the IPv4 Public IP address of your AWS instance, so you can use it when we connect to the instance using SSH in Step 3.
Step 3: Connect to your Instance
- After launching your instance, it's time to connect to it using SSH.
- Windows users: Select Windows below to see instructions for installing Git Bash which includes SSH.
- Download Git for windows from https://git-scm.com/download/win and install Git.
- Right click on your desktop (not on an icon or file) and select Git Bash Here to open a Git Bash command prompt.
- Use SSH to connect to your instance. In this case the user name is ec2-user, the SSH key is stored in the .ssh directory with name MyKeyPair, and the IP address are IPv4 Public IP address that we saved from previous step. Put all these details in given format
- We can create programs like shell script or python program using nano editor in VM. Here I am creating a simple shell script
- You can notice that when I execute my simple shell script, it responds me if I am running a Linux machine but actually right now I am using a Windows machine. That’s the advantage of using VM over AWS.
Step 4: Terminate Your Instance
You can easily terminate the instance from the EC2 console.
In fact, it is a best practice to terminate instances you are no longer using
so you don’t keep getting charged for them.
I hope this article would help some one who is interested to make quick start on AWS services such as EC2 using Free tier account.
Keep learning and do comment your feedback!
No comments:
Post a Comment