DevOps Training
  • DevOps
  • What is DevOps
    • What DevOps Look like
    • Why DevOps Needed
    • DevOps Automation Tools
    • DevOps Principles
  • cloud computing
    • How DevOps links with Cloud Computing
    • What is cloud computing?
      • Platform as a service (PaaS)
      • Infrastructure as a service (IaaS)
      • Software as a service (SaaS)
      • Function as a Service
      • SaaS, PaaS, IaaS
  • Version Control
    • Git as Version Control
      • Setting up Remote Repo
      • Git Hooks
      • github vs gitlab vs bitbucket
      • Quick Recap Git
  • DevOps #01 Continuous Integration
    • Continuous Integration & Continuous Delivery
      • Understanding CI Tools
      • Prerequisite
      • Continuous Integration
      • CI Tools
      • Travis-CI
        • Travis CI with S3
        • Static Site Build S3
        • Beanstalk with AWS CLI
          • Elastic Beanstalk with Travis CI
        • Travis using Code Deploy EC2
          • Github and Code Deploy
          • Travis CI with Code Deploy
      • Gitlab-CI
        • CI Setup for application
        • Gitlab Runners on EC2
        • CI Integration with AWS
          • Deploying App using Gitlab CI
          • Gitlab CI with AWS S3
          • Gitlab CI with ECS
          • CI Integration with EC2
            • Update and Clean Gitlab.yml
        • Install Gitlab on EC2
      • CI/CD using Jenkins CI
        • Jenkins Build on EC2
        • Jenkins Build EC2 Ubuntu
        • Jenkins CI/CD
          • Create a Build Item
          • Create a Build Pipleine
            • Pipeline Using Docker
            • Pipeline Examples
          • Jenkins CI with S3
            • Jenkins CI - S3
          • Jenkins CI with EC2
    • Jenkins CI Cluster Mode
    • AWS Code Pipeline CI/CD
      • AWS CI/CD Tools
        • AWS Code Build
        • AWS Code Deploy to Beanstalk
        • AWS Code Deploy to EC2
        • AWS Pipeline - Example CI/CD
  • Docker
    • Docker
      • Docker for Developers
        • Install and setup
        • Docker Commands
        • Docker Images Container
        • Docker Architecture
    • Docker Demos
      • Node JS Container
    • Docker-compose
      • Using Docker Compose
      • Docker Compose Demo
  • AWS Quick Refresh
    • AWS Quick Recap - Videos
    • AWS Quick Recap
  • AWS Architecture - Lab
    • Application Deployment - 01
    • Application Deployment - 02
    • Application 3 tier Architecture
  • Basic Networking
    • Computer Networking for Beginners
      • Basic of Networking
      • Networking Protocols
      • OSI Model
      • Network address and Host address
      • Subnetting Type
    • Network Architecture
    • Networking Layers OSI Model
    • Internet protocol
      • CIDR and subnetting
        • Examples
      • AWS VPC Subnets
  • VPC and Networking
    • AWS VPC
    • VPC Demo
      • Bastion Host | Jump Server
  • AWS Components
    • AWS Components In Depth
      • AWS Storage
        • AWS EBS
        • AWS Cloudfront
        • AWS S3
      • AWS Compute
        • ECS
        • AWS VPC
          • VPC Components
        • AWS EC2
        • AWS ELB
          • Application Load balancer
            • Example
        • AWS EC2 Auto Scaling
          • Demo
        • AWS Route 53
        • AWS Lambda Serverless
          • AWS Lambda Serverless Computing
  • Assignments
    • Assignment 01-Node JS app on EC2
    • Assignment 02-Node JS with Mysql
    • Assignment-03
  • Microservices
    • Microservices Architecture
      • Docker and Docker-Compose
      • Docker-Compose Example 01
      • Docker-Compose Example 02
      • Hand-on | Building Microservices
    • Architecture Components
  • AWS ECS
    • AWS ECS
      • Introduction of ECS
Powered by GitBook
On this page
  • Choose the type of Operating System for our EC2 Virtual Machine
  • Select the type of Memory and CPU usage we want on our virtual machine
  • Configure the virtual machine and select a pricing plan
  • Select storage option for Elastic Beanstalk (EBS)
  • Add Tags (optional for now)
  • Create a Security Group
  • Launch the instance from the AWS dashboard
  • SSH into our machine to install the web server
  • Add an index.html for the internet to see

Was this helpful?

  1. AWS Components
  2. AWS Components In Depth
  3. AWS Compute

AWS EC2

PreviousVPC ComponentsNextAWS ELB

Last updated 5 years ago

Was this helpful?

Log into the AWS console. Select EC2 and then Launch Instance:

Choose the type of Operating System for our EC2 Virtual Machine

The Amazon Linux AMI comes with a whole lot of pre-built in tools including the AWS CLI, the popular programming languages and databases.

(Note: For large scale applications you may have to use Amazon’s Relational Database Service (RDS) or DynamoDB but is not necessary for this tutorial.)

Select Amazon Linux AMI:

Select the type of Memory and CPU usage we want on our virtual machine

Next we’ll have to select the type of EC2 instance we want to boot up. There are ten types of EC2 instances: Dense Storage (D2), Memory Optimized (R4), General Purpose (M4), Compute Optimized (C4), Graphics Intensive (G2), High Speed Storage (I2), Field Programmable Gateway (F1), Lowest Cost General Purpose (T2), Graphics General Purpose (P2) and Memory Optimized (X1).

Select T2 and then “Next: Configure Instance Details”

Configure the virtual machine and select a pricing plan

Next we’re going to configure our instance details. There are four different pricing models for EC2 instances: On Demand, Spot, Reserved and Dedicated Hosts.

For the most part we’re going to leave the defaults:

VPC stands for Virtual Private Cloud. One subnet is tied to one Availability Zone. IAM stands for Identity Access Management and is used to manage permissions. In the advanced section we can pass bootstrap shell scripts to our EC2 instances to do things like install PHP or Apache.

The next part relates to Elastic Beanstalk (EBS). EBS is used to create storage volumes that attach to EC2 virtual machines. With EBS we can create filesystems, run databases and other cool stuff.

There are three different storage types for root EBS volumes: General Purpose SSD (GP2), Provisioned IOPS SSD (IO1) and Magnetic HDD. SDD stands for Solid State Drive and HDD is Hard Disk Drive.

Select storage option for Elastic Beanstalk (EBS)

EBS Volume is a virtual hard disk in the cloud. Root means it is where we are going to boot our Operating System from (such as Windows or in our case Linux).

Delete on Termination means the EBS will be deleted if we delete the EC2 instance.

Add Tags (optional for now)

Tags help you control costs. They help you see where your AWS costs are coming from. Tag everything and tag as much as possible.

Create a Security Group

Security Groups are virtual firewalls. We are going to create a Security Group called MyWebDMZ. The Security Rules define what type of traffic we want to allow through. We want to SSH into our EC2 so we can do things like install Apache. We want to view the website so we’ll allow HTTP and HTTPS.Create a new security group. The warning is because we did not restrict the IP address source of who can SSH into our virtual machine.

Launch the instance from the AWS dashboard

Review the instance and hit Launch.

We will get a dialog where we will create a Public and Private key pair. Do not let anyone know your private key or they will be able to hack your virtual machines.First click Download Key Pair and then Launch Instances.

After the instances launch we’ll get to a landing page where you can select View Instances (bottom right corner).

SSH into our machine to install the web server

Grab your IPv4 Public IP address from the bottom right corner in the Description section.

Create a new folder for your SSH keys and change the permissions. I downloaded my key pair to projects folder. So change into that directory and run the following commands:

$ mkdir SSH
$ mv MyEC2KeyPair.pem SSH
$ cd SSH
$ chmod 400 MyEC2KeyPair.pem
$ ssh ec2-user@54.210.39.128 -i MyEC2KeyPair.pemThe authenticity of host '54.210.39.128 (54.210.39.128)' can't be established.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '54.210.39.128' (ECDSA) to the list of known hosts.__|  __|_  )_|  (     /   Amazon Linux AMI___|\___|___|https://aws.amazon.com/amazon-linux-ami/2017.03-release-notes/1 package(s) needed for security, out of 1 availableRun "sudo yum update" to apply all updates.[ec2-user@ip-172-31-16-8 ~]$
[ec2-user@ip-172-31-16-8 ~]$ sudo su[root@ip-172-31-16-8 ec2-user]# yum update -y
[root@ip-172-31-16-8 ec2-user]# yum install httpd -y
[root@ip-172-31-16-8 ec2-user]# cd /var/www/html
[root@ip-172-31-16-8 html]# nano index.html

Add an index.html for the internet to see

Write some HTML:

Then hit Ctrl+X and then Y that yes you want to save your changes. Then hit enter that you want to save this to index.html.

Start Apache:

[root@ip-172-31-16-8 html]# service httpd startStarting httpd:                                            [  OK  ]

Next navigate your web browser to your public IP address and you will be able to see your web page hosted on Amazon Web Services in the cloud.

That is a lot of options. Below is a visual that groups these different types. We’re going to use the smallest and most general type of instance: T2 Micro.Grouping of various EC2 instance types ()

More details:

Read More:

Read More:

Read More:

Make ourselves a super user and update our operating system and install Apache (aka ):

In my case the web page was served on (my public ip address for the virtual machine we created)

photo credit
Amazon EC2 Instance Types
Amazon EC2 Pricing
Amazon EBS Volume Types
Tagging Your Amazon EC2 Resources
httpd
http://54.210.39.128/