Amazon Elastic Cloud Compute(EC2) is an Infrastructure as a Service (IAAS) provided by Amazon. It provides secure, resizable compute capacity, in the cloud. It mainly consists of the capabilities:
- Virtual computing environments, known as instances
- Ready to use EC2 instances, known as Amazon Machine Image(AMI)
- Various configurations of CPU, memory, storage, and networking capacity for your instances, known as instance types
- Secure login information for your instances using key pairs
- Storing data on virtual drives, Amazon EBS volumes
- A firewall that enables you to specify the protocols, ports, and source IP ranges that can reach your instances using security groups
- Static IPv4 addresses for dynamic cloud computing, known as Elastic IP addresses
- Metadata, known as tags, that you can create and assign to your Amazon EC2 resources
- 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 Cloud (VPC)
- Distributing load across machines using Elastic Load Balancer(ELB).
- Scaling the services using an Auto-Scaling Group(ASG).
- Bootstrap script: configure at the first launch using EC2 User Data.
Creating your EC2 instance
- Log into your AWS account using your IAM credentials
- Launch your instance: Identify which instance type is best and choose an AMI.
- Configure your instance: security groups, VPC, storage, subnet, IAM role
- Connect to your instance: using ssh, putty, or EC2 Instance Connect
- Terminate your instance: once the task is completed delete the instance to prevent additional charges.
Amazon Machine Image (AMIs)
EC2 AMIs are the templates that are configured with an operating system (Windows, Linus, macOS) and other software configurations to launch an instance.
An AMI is a virtual image used to create a virtual machine within an EC2 instance. You can also create multiple instances using a single AMI when you need instances with the same configuration. There are three types of AMIs: Public AMI, your own AMI, and an AWS Marketplace AMI.
An instance is a virtual server in the cloud. From an AMI, you launch an instance, which is a copy of the AMI running as a virtual server in the cloud. An instance type determines the hardware of the host computer used for your instance.
EC2 Instance types:
1. General Purpose: they have a balance between compute, memory, and networking such as web servers. For example, t2.micro is a general purpose instance type.
2. Compute Optimized: these are great for compute-intensive tasks that require high-performance processors such as high-performance computing, scientific modeling and ML, dedicated gaming server, etc. They start usually with C, eg, C5.
3. Memory Optimized: Fast performance of workloads that process large datasets in memory. They are the R(RAM) series.
4. Storage Optimized: they are great for storage-intensive tasks that require high sequential read and write to large datasets on local storage.
- Security groups act as a firewall at the instance level. If traffic is blocked by a security group it will not be visible by EC2.
- They can be attached to multiple instances.
- All inbound rules are blocked by default and all outbound traffic is authorized by default.
- When you launch an instance, you can specify one or more security groups. If you don’t specify a security group, Amazon EC2 uses the default security group.
- You can add rules to each security group that allows traffic to or from its associated instances. You can modify the rules for a security group at any time. New and modified rules are automatically applied to all instances that are associated with the security group. When Amazon EC2 decides whether to allow traffic to reach an instance, it evaluates all of the rules from all of the security groups that are associated with the instance.
- Security groups are stateful, i.e., if you create an inbound rule allowing traffic in, that traffic is automatically allowed back out again.
- If your application gives ‘time out’ it is a security group issue.
In the next post, I will explain EC2 storage(Elastic Block Storage(EBS), Elastic File System(EFS), and Instance Store), Elastic Load Balancer(ELB), Auto Scaling Groups(ASG), and EC2 Pricing models.