How To Create, Manage And Delete An AWS EC2 Instance Using The AWS Web Console, Putty And / Or The MacOS Terminal.

The AWS cloud computing platform is one of the worlds leading  cloud computing service provider with a large range service offerings. On AWS you can deploy almost any operating system, enterprise application bundled in a amazon machine image, host almost any relational or non relational database, create a fully fledged virtual private cloud (VPC) and so much more!. However before you can start working on and deploying advanced AWS services it is important to know just the basics such as provisioning an AWS EC2 instance and connecting to the instance via SSH. This tutorial provides an easy to follow how to guide on doing just that. We’ll also show you how to setup a static Elastic IP address so you can reliably connect to the amazon EC2 instance.

Requirements.

In order to complete this tutorial successfully the following items are required. Please ensure to have these items available before taking implementation action on this tutorial:
1) An AWS free tier account and an AWS IAM user account with access rights to provision AWS EC2 instances
2) An SSH client such as Putty
3) An internet connection with atleast 5Mbps bandwidth
4) The AWS Amazon Linux machine image.

Overview.

1) Create a FREE tier AWS account and setup an IAM user account. If you already have an AWS account login using your IAM user account
2) Create an Amazon Linux Instance and set an Elastic IP address on it.
3) Learn how to connect and manage the the Amazon Linux instance using an SSH client such as putty or the MacOS terminal
4) Learn how to stop or delete the Amazon Linux instance.

Step 1: Create Or Sign Into Your AWS account.

1) In order to make it easier for  new comers to sign up and start deploying work loads in the cloud, AWS created a free tier program that allows almost anyone with basic IT skills to start using their service with no upfront cost.

If you are an AWS new comer click HERE to sign up for a FREE TIER account. Please note that you will need a working VISA or MASTERCARD enabled bank card with atleast $ 5 USD credit to sign up.

2) You when you sign up on AWS for the first time, your account is the root user account. This means that if your AWS account is breached you could loose everything. By using IAM you can control which users have access to what AWS features, the kinds of actions they can perfom and services they can have access to. You can even keep track of user activity using AWS CLOUDTRAIL so its so much easier to keep tabs on USER and API activity.

To create an IAM user account click on SERVICES and search for IAM. Click on the IAM search result to open the IAM MANAGEMENT CONSOLE, click on the USERS tab and click on the ADD USERS button.

Type in a username, set your preferred AWS access type options and click on the PERMISSIONS button Choose the CREATE GROUP option or click on the default EC2ADMINISTRATORS option and click on the NEXT: TAGS button

Tags allow you to set items such as a user’s job role or office location. Add any tags that you wish to set for the user and click on the NEXT: REVIEW button then click on the CREATE USER button.

 

Step 2: Sign Into Your AWS IAM User Account And Create The Amazon Linux EC2 Instance.

3) Copy the IAM users sign-in link that is on the IAM dashboard, sign out of your root AWS account and use the sign-in link to sign into AWS.  Click on SERVICES and click on EC2. Click on the orange LAUNCH INSTANCE button.

From the QUICK START tab click on the blue SELECT button on the “Amazon Linux 2 AMI (HVM), SSD Volume Type” option.

4) If you are using a FREE tier account, click on the t3.micro instance type that is marked as FREE TIER ELIGIBLE and click on the REVIEW AND LAUNCH button.

5) On the REVIEW INSTANCE LAUNCH step you can perfom operations such as changing the instance type, editing security groups, storage, tags and more. If there are no changes to be made click on the LAUNCH button.

6)  A popup message will be displayed and ask you to select an existing key pair or to create a new key pair. Key pairs are made up of a private and public key and together they  create a much more secure way to connect and authenticate to an EC2 instance.

Select the CREATE A NEW KEY PAIR option, type in a any name for the keypair on the KEY PAIR NAME text box and click on DOWNLOAD KEY PAIR.

Proceed by clicking on LAUNCH INSTANCES then click on VIEW instances.

Step 3: Set An Elastic IP Address.

7) An Elastic IP Address is a reserved public IP address taken from the AWS public IP address pool that can be assigned to an AWS EC2 instance. It is also possible to bring a public IPv4 address that you already own to the AWS platform.

To reserve an Elastic IP address click on the ELASTIC IP’s option and click on ALLOCATE ELASTIC IP ADDRESS. Click on the “Amazon’s pool of IPv4 addresses” option and click on ALLOCATE.

8) The next step is to associate the elastic ip address to the Amazon Linux instance. Click on the ACTIONS button and select the ASSOCIATE ELASTIC IP ADDRESS option. 

On the ASSOCIATE ELASTIC IP ADDRESS page set the RESOURCE TYPE option to INSTANCE. Select the  AMAZON LINUX instance on the INSTANCE search box and click on ASSOCIATE.

Step 4: Connect To The Instance Using An SSH Client.

9) The next step is to change the file permission of the AMAZON LINUX key pair to read only. This ensures that the file is not publicly viewable. If you are using a Mac, open the MacOS terminal and go to the directory where the key pair is  saved and run the following command:

chmod 400 YOUR_KEY_PAIR_FILE_NAME.pem

If you are using a Windows PC, you’ll need to convert the key pair file using PUTTYGEN before you can connect, click HERE to learn how to do just that.

10) To connect to the AMAZON LINUX instance via SSH run the following command on the MacOS terminal.

ssh -i “YOUR_KEY_PAIR.pem” root@your_ec2_public_dns.compute.amazonaws.com

You now can start to install you custom apps on the AWS instance. The next step shows you how to stop or delete an AWS instance.

Step 5: Learn How To Stop Or Delete An AWS Instance.

11) If you would like to stop an AWS instance you can do so from the EC2 MANAGEMENT CONSOLE. Simply right click on the instance and click on INSTANCE STATE >STOP INSTANCE.

12) If you would like to delete or terminate an AWS instance right click on the instance and click on INSTANCE STATE >TERMINATE INSTANCE. Be sure sure to also delete the EBS volume if you do not wish to reuse it and also to disassociate any associated Elastic IP addresses.