Just Another AWS EC2 Tutorial

Gaurav Pareek
6 min readDec 20, 2020

AWS EC2 is probably one of the most popular service under Amazon Web Services (AWS) Cloud and is a web service which allow secure and resizable compute capacity on the cloud. It provides its users the facility to run their compute workloads in any of the regions across the world. EC2 or Amazon Elastic Compute Cloud forms a part of AWS to provide web services and would be one of the early services introduced by AWS.

Features and Benefits

Scaling Features: AWS EC2 Autoscaling scales up or down beautifully users face many hassles when working with applications that require more resources for a short period of time. EC2, due to its easy scaling feature is highly responsive to capacity requirement changes.

Highly Flexible: EC2 is highly flexible with it’s CPU and memory size that can be chosen by the user at the stage of deployment. Along with this, if a user wants to increase CPU or memory size on the go they can do that pretty easily.

Secure Access Using IAM Roles: I believe accessing AWS Services using IAM Roles is an added layer of security and smart way of accessing AWS services rather than using Access Keys. You can integrate IAM Role with almost all the AWS Services and access them through your EC2 Instances but I’m listing some of the popular ones:
a) S3
b) SQS
c) RDS

Accessing EC2 Boxes Console Using Systems Manager (New Service): Initially, when you had to access the EC2 instance you had to do SSH to access linux boxes. With AWS Systems Manager, AWS provides you an access to your boxes using browser itself. It saves the hassle of whitelisting IP’s and makes lives of SysOps easy.

Cost-effectiveness: Hourly rates offered by EC2 are a very attractive bargain and if you’re comfortable with longer commitments and predictable workloads. I would suggest to go with Reserved Instances it can give you cost reduction by upto 75%

Sizes of Instances: AWS EC2 provides various instances configurations based on your workload requirements like General Purpose (t2, t3), Memory Optimized (R series), Apple Mac mini computers(Mac), Arm based workloads (A series), Compute Optimized (C series) and many more.

How to put these easy to use effective tools to optimum utility?

1. Launch ‘instance’ from EC2 console.

2. Select the AMI that suits you.

  • The base image of the instance can be seen in the AMI. An AMI can be a base image for the instance. An AMI can be just the base operating system or a full blown stack.
  • AMI’s gives you variety of options like community AMIs, Marketplace or even private AMIs that are meant to be used by the organization only.
  • The Marketplace offers third-party AMIs, such as appliances like the enterprise tools.

3. Choosing the best instance type.

I would suggest to take advantage of FREE tier eligible instance type.

Since you are free to change the instance type to higher or lower, it is always better to be conservative. It drastically reduces costs. Also, make sure that you benchmark and try choosing the right EC2 instance.

4. Configuration details.

Enter the following details:

  • Number of instances to provision.
  • Spot instances are available. It costs less than an EC2 instance as it is bought through bidding. A spot instance need not be accessible at all times.
  • Select your network details like VPC or the subnet. VPC public subnets have the option to override the settings of public IP assignment.
  • Access to AWS resources can be obtained through IAM role.
    Example: Your application wants to access S3. Assigning an IAM role to the EC2 instance that permits it will do the job for you. The advantage of this method is that it eliminates the requirement to store secret keys and access to the file system itself.
  • The shutdown pattern can be set by the user.
  • Important instances like infrastructure servers can be protected by enabling the termination protection flag.
  • User data section: The script which is run on the first boot can be specified here. One-time configurations like the installation of CloudWatch can be done through this method.

5. Adding Storage.

  • EBS (Elastic Block Store) volumes are used in the file system. The user can select the size.
  • The storage type for use is determined by the volume type.
  • The GP2 storage suits different workloads since it is SSD based. Temporary escalation of demand is met through burst capabilities to give higher IOPS.
  • Using IO1 type is suitable for intensive components to deliver guaranteed IOPS.
  • Sequential access like ETL workloads can be run using magnetic volumes.
  • Sometimes compliance and security compulsions require encrypting data at rest features.

6. Adding Tags.

A logical name should be assigned to the EC2 by specifying the name tag. All tags associated with the instance can be entered. Other purposes for which tags are usually specified include billing and ownership identification.

7. Security Group of the Instance.
There are rules which allow or control access through a virtual firewall. It can be coupled with the instance to limit access.

8. Launching.
Make sure that the entered values are scrutinized before launching the instance. The interface has an edit button that allows the user to change values.

9. Key Pair.

Before making the launch to take effect, the developer is required to use an existing key pair or create a new one.

  • Connecting the EC2 instance for Windows and Linux through SSH requires a password. It is obtained using a key pair.
  • The user will be required to create a key pair for the first launch on the platform. Once the key pair has been generated, make sure to store it securely.

Within a few minutes of completing the above procedures, the instance will come into existence.

10. Activating the Instance

The new instance will run after completing successful provisioning.

11. Reviewing

The EC2 has a list that contains the names of all instances. Click on the Instances tab to review details. The EC2 has a list that contains the names of all instances. Click on the Instances tab to review details.

  • The information includes DNS name and public IP. Other details are instance type, identifier, and name.
  • More details can be seen below. They are:
    Storage information, Subnet, AMI, Private IP

The lifespan of Private and Public IPs

  • A private IP cannot be changed. It is there to stay as long as the EC2 instance exists.
  • Public IP will change with each reboot. This does not apply to elastic IPs.

The best practices for an EC2 user are given below:

Your AWS account should not contain any EC2 instances that are blacklisted.

AMIs which have been in the AWS account for over 180 days should be changed.

There is a limit that has been set for the EC2 Instances. Check periodically to make sure that the limit has not exceeded.

You should not overcrowd the security groups with very large numbers of defined rules.

AWS has a set a limit for the Elastic IPs that can be allotted. Periodically ensure that your account has not crossed the limit.

I’m an AWS expert and AWS Certified Architect, AWS Certified Sysops Administrator and AWS Developer Associate. I take up AWS assignments. You can reach me on gaurav.ideabox@outlook.com or check our my Linkedin. I will get back to you.

--

--

Gaurav Pareek

DevOps and AWS Certified Architect | Technology Enthusiast with deep interest in Cloud Solutions. Linkedin: https://www.linkedin.com/in/gauravpareekaws/