Exploring Compute Services: EC2
What is AWS EC2?
Amazon Elastic Compute Cloud, EC2 is a web service from Amazon that allows you to rent and manage virtual servers in the cloud.
Features of Amazon EC2
Amazon EC2 provides the following features:
1. Virtual computing environments, known as instances
2. Preconfigured templates for your instances, known as Amazon Machine Images (AMIs), that package the bits you need for your server (including the operating system and additional software)
3. Various configurations of CPU, memory, storage, and networking capacity for your instances, known as instance types
4. Secure login information for your instances using key pairs (AWS stores the public key, and you store the private key in a secure place)
5. Storage volumes for temporary data that are deleted when you stop, hibernate, or terminate your instance, known as instance store volumes
6. Persistent storage volumes for your data using Amazon Elastic Block Store (Amazon EBS), known as Amazon EBS volumes
7. Multiple physical locations for your resources, such as instances and Amazon EBS volumes, known as Regions and Availability Zones
8. A firewall that enables you to specify the protocols, ports, and source IP ranges that can reach your instances using security groups
9. Static IPv4 addresses for dynamic cloud computing, known as Elastic IP addresses
10. Metadata, known as tags, that you can create and assign to your Amazon EC2 resources
11. Virtual networks you can create that are logically isolated from the rest of the AWS Cloud and that you can optionally connect to your own network, known as virtual private clouds (VPCs)
Use Cases: EC2 in the real world
- Deploy a database: Deploying a database to EC2 gives you full control over the database.
- Deploy a web application: Deploy to multiple AZs to make the web application highly available.
Methods to access an EC2 instance
- AWS Management Console
- Secure Shell (SSH)
- EC2 Instance Connect (EIC)
- AWS System Manager
Components of AWS EC2
- Amazon Machine Image (AMI): Amazon Machine Image is like a preconfigured template to launch an EC2 instance with Operating systems, tools, applications, and more. You can choose AMI based on the project or usage.
- Instances: An instance is a virtual server in the cloud. Its configuration at launch is a copy of the AMI that you specified when you launched the instance. You can launch different types of instances from a single AMI.
- Storage for your instance-The root device for your instance contains the image used to boot the instance. The root device is either an Amazon Elastic Block Store (Amazon EBS) volume or an instance store volume. EBS is a storage service that is attached to EC2 to store data it’s just like a hard drive.
EC2 Pricing Options
- On-Demand: A fixed price in which you are billed downed to the second based on the instance type. There is no contract, and you pay only for what you use.
- Spot: Spot instances let you take advantage of unused EC2 capacity. Your request is fulfilled only if capacity is available
- Reserved Instances: Reserved Instances allow you to commit to a specific instance type in a particular region for 1 or 3 years.
- Dedicated Hosts: Dedicated Hosts allow you to pay for a physical server that is fully dedicated to running your instances.
- Savings Plan: Savings Plan allows you to commit to compute usage(measured per hour) for 1 or 3 years.
Create Your First Amazon EC2 Instance (Linux)
1-Select Services>EC2 from the AWS Management Console home page:
You are now in the EC2 Dashboard
2-Click Launch Instance
A seven-step wizard is started
3-Click the top Select button to choose the Amazon Linux 2 AMI
4-Choose any Instance Type
5-Click Next: Configure Instance Details when ready to continue
6-Click Next: Add Storage
The Add Storage page enables you to further configure storage options:
7-Click Next: Add Tags when ready
The Add Tags page provides a helpful way to organize your EC2 instances:
8-Click Next: Configure Security Group when ready
Read the supporting text near the top of the Configure Security Group page of the wizard:
The Warning from AWS is letting you know the default configuration for the security group that is about to be created will grant SSH access from any source IP address(0.0.0.0/0). Production environments should be more restrictive.
9-Click Review and Launch when ready
Be sure to look over the Instance Type, Instance Details, and Storage sections.
10-Click Launch when ready
11-In the Select an existing key pair or create a new key pair dialog box, select Create a new key pair. Enter keypair for the Key pair name, keep the default value for the Key pair type, and then click Download Key Pair:
The download will create a file named keypair.pem on your local system. It contains a private key that you can use to connect to the EC2 instance via SSH
12-Click Launch Instances
13-Click the View Instances button (lower right) to close the confirmation page and return to the Instances screen of the EC2 console.
You can view the status of your instance on the Instances screen of the EC2 console:
Thanks, everyone for reading
If you found this informative, do not forget to clap👏 and do let me know if you have any doubts
Support me if you like my work! Buy me a coffee