RUNNING VIRTUAL SERVERS IN THE CLOUD
Elastic Compute Cloud ≙ (EC2) is one of Amazon's infrastructure as a Service offerings for a broad range of compute requirements, including more than 500 instances with different processors, storage, operating systems and networking capabilities. It's one of the most mature services, released back in 2006!
Between the launch and the termination of your EC2 instance, there more lifecycle states it transitions through:
EC2 instances are virtual machines (VMs) in the cloud. Contrary to physical servers, virtual instances software to create an abstraction from their underlying hardware. This allows securely hosting multiple virtual machines (from different AWS customers) on the same physical hardware.
An instance comes with strong performance and security guarantees, even when the underlying is shared, as AWS dedicates some resources of the host computer such as CPU, memory, and instance storage to the particular instance.
AMIs are AWS-maintained configurations that are required to launch an instance. It contains the operating system (e.g. Amazon Linux 2), architecture (32/64-bit ARM or x86-64 install), launch permissions, and storage for the root device.
Developers can also create shared images (Shared AMIs) that are made available for others to use. AWS can't ensure the integrity or security of these AMIs, so it's within your own responsibility.
Launching an instance requires you to specify an instance type. This determines the hardware capabilities of the host that is used for your virtual machine.
The instance types are grouped into instance families:
Key-pairs allow you to securely access your EC2 instances from any location via SSH. If you're launching a new instance, you'll be prompted to either create a new public & private key set or use an existing one. When generating a new pair, AWS will store the public part on the instance (concretely at ~/.ssh/authorized_keys), while asking you to download the private part afterwards. So if you lose it, you can't recover it.
You can also use AWS Systems Manager Session Manager to connect via a browser-based shell or AWS CLI.
As an alternative, you can solely rely on AWS IAM to connect to your instances, not needing to manage any key-pairs. This is achieved with EC2 Instance Connect.
EC2 provides different purchase options with drastically varying in pricing. If you plan to use EC2 regularly, it's a duty to understand the purchase options:
While many AWS-provided AMIs come with additional software, especially for software development purposes it most likely doesn't include all the software you need.
As described earlier, shared AMIs come to tackle this issue. Additionally, there are shared images that are also paid and therefore increase the price for your instance types. When selecting a paid AMI from AWS Marketplace you'll be informed about the additional usage fees.
EC2 comes with a diverse set of possible storage options, each with a unique combination of durability and performance.
Regardless of your requirements, there will be a great fit for you:
There is a variety of services that helps you to monitor the availability and performance of your instances.
The simplest tools are system status checks and instance status checks. System status are provided and taken care of by AWS and detecting problems with the software or physical hardware, e.g. network connectivity or power loss. Instance status checks are there to detect configuration issues that need to be addressed by yourself, including misconfigured network or exhausted memory.
CloudWatch and EventBridge help you gain more insights into your instances and also react to incidents with automated routines. EC2 automatically sends metrics to CloudWatch, including CPU utilization as well as network and disk usage.
You're able to organize your instances into logical groups that can be scaled to scale based on policies, including: