DEV Community

Cover image for Introduction to Amazon EC2 and Creating an EC2 Instance in AWS
Trivikram Majjari
Trivikram Majjari

Posted on

Introduction to Amazon EC2 and Creating an EC2 Instance in AWS

Introduction to Amazon EC2

Amazon EC2
Amazon Elastic Compute Cloud (EC2) is a web service that provides secure, resizable compute capacity in the cloud. It's designed to make web-scale cloud computing easier for developers and businesses of all sizes.

Why Amazon EC2?

Amazon Elastic Compute Cloud (Amazon EC2) offers the broadest and deepest compute platform, with over 750 instances and choice of the latest processor, storage, networking, operating system, and purchase model to help you best match the needs of your workload. We are the first major cloud provider that supports Intel, AMD, and Arm processors, the only cloud with on-demand EC2 Mac instances, and the only cloud with 400 Gbps Ethernet networking. We offer the best price performance for machine learning training, as well as the lowest cost per inference instances in the cloud. More SAP, high performance computing (HPC), ML, and Windows workloads run on AWS than any other cloud.

Benefits:

1. Elasticity and Scalability

  • Scale capacity up or down within minutes
  • Automatic scaling with Auto Scaling groups
  • Pay only for what you use

2. Complete Control

  • Root/administrative access to instances
  • Choose your operating system
  • Configure security and networking
  • Manage storage options

3. Flexibility

  • Multiple instance types optimized for different use cases
  • Choice of operating systems and software packages
  • Various purchasing options (On-Demand, Reserved, Spot instances)

4. Security

  • Virtual Private Cloud (VPC) for network isolation
  • Security Groups for firewall configuration
  • Integration with AWS IAM for access control
  • Encryption options for data at rest and in transit

5. Reliability

  • Multiple Availability Zones
  • High availability options
  • Automated backups and recovery
  • Health monitoring and auto-recovery

Pricing Options:

1. On-Demand Instances

  • Pay by the hour or second
  • No upfront costs or long-term commitments
  • Best for short-term, irregular workloads

2. Reserved Instances (RI)

  • Up to 72% discount compared to On-Demand
  • 1 or 3-year term commitment
  • Payment options: No upfront, Partial upfront, All upfront

3. Spot Instances

  • Up to 90% off On-Demand prices
  • Ideal for flexible start and end times
  • Good for batch processing, scientific research

4. Dedicated Hosts

  • Physical servers dedicated to your use
  • Can help address compliance requirements
  • Allows you to use existing server-bound software licenses

Here's a detailed guide to create an EC2 instance with associated networking components in AWS:

Create a VPC (Virtual Private Cloud):

  1. Navigate to VPC Dashboard in AWS Console
  2. Click "Create VPC" named my-vpc-01 .
  3. Specify CIDR block (e.g., 10.0.0.0/16)
  4. Enable DNS hostnames and DNS support

Image description

Image description

Create Subnets:

  1. Create at least two subnets (public and private) in different availability zones
  2. For public subnet: e.g., 10.0.1.0/24
  3. For private subnet: e.g., 10.0.2.0/24
  4. Enable "Auto-assign public IPv4 address" for public subnet

Image description

Image description

Create Internet Gateway (IGW):

  1. Create a new Internet Gateway
  2. Attach it to your VPC

Image description

Image description

Create Route Tables:

  1. Create a public route table
  2. Add route to Internet Gateway (0.0.0.0/0 → IGW)
  3. Associate public subnet with this route table
  4. Create a private route table for private subnet

Image description

Image description

Image description

Configure Security Group:

  1. Create a new security group in your VPC
  2. Add inbound rules for required ports:
    • SSH (Port 22) from your IP
    • HTTP (Port 80) if needed
    • HTTPS (Port 443) if needed

Image description

Launch EC2 Instance:

  1. Click "Launch Instance" in EC2 Dashboard
  2. Choose an Amazon Machine Image (AMI)
  3. Select instance type (e.g., t2.micro)
  4. Configure network settings:
  5. Select your VPC
  6. Choose public subnet if you need internet access
  7. Enable auto-assign public IP
  8. Select the security group you created
  9. Add storage as needed
  10. Create or select a key pair for SSH access
  11. Review and launch

Image description

Image description

Image description

Hurray! myinstance-01 is successfully created and running on AWS Cloud.

Best Practices:

  • Right-sizing: Choose appropriate instance types
  • Use Auto Scaling for optimal resource utilization
  • Implement proper security measures
  • Regular backup and disaster recovery planning
  • Monitor and optimize costs using AWS Cost Explorer

Conclusion

Amazon EC2 stands as a foundational pillar in AWS's cloud computing infrastructure, offering a comprehensive solution for businesses of all sizes. Through its flexible computing resources, diverse pricing models (including On-Demand, Reserved, and Spot instances), and robust security features, EC2 enables organizations to significantly reduce their IT infrastructure costs while maintaining high availability and scalability. The service's seamless integration with the AWS ecosystem, coupled with features like Auto Scaling, load balancing, and detailed monitoring through CloudWatch, allows businesses to focus on their core operations rather than infrastructure management. Whether deploying a simple web application or running complex enterprise workloads, EC2's ability to provide secure, resizable compute capacity, combined with its pay-as-you-go pricing model and extensive management tools, makes it an invaluable resource for modern cloud computing needs. By following best practices such as right-sizing instances, implementing proper security measures, and maintaining regular backups, organizations can leverage EC2 to achieve optimal performance, cost-effectiveness, and reliability in their cloud infrastructure.

Top comments (0)