{{< partial "learn_x_header" >}}
## The Basics
Learn EC2 basics, concepts, and more.
Amazon EC2 is the core computing service provided by Amazon Web Services. It's [Virtual Machines] in the cloud.
If you have been using Amazon Web Services for a while, you've undoubtedly encountered EC2. It is a central service used by [Amazon LightSail] and numerous other offerings.
### Primary Use Cases
1. Hosting environments for your apps
2. High-performance computing
3. Computing with more specific use cases like:
1. GPU Heavy Tasks
2. High Memory Requirements
3. Burstable compute
### When to Use EC2?
Use EC2 when you need to run a virtual machine in the cloud. EC2 is a versatile service that can meet a wide range of use cases.
## Launch Template
Defines the launch parameters for an EC2 instance.
It includes the ID of the Amazon Machine Image (AMI), the instance type, a key pair, security groups, and other parameters used to launch EC2 instances.
Use a [launch template] instead of the deprecated launch configuration.
## Auto Scaling Groups
A definition of how many instances you want to run within a cluster, along with thresholds on when to expand to the size of the cluster.
[AWS::AutoScaling::AutoScalingGroup]
## Instances
EC2 Instances are central to the ecosystem. To use EC2, you will launch an EC2 instance from an EC2 image. An EC2 image contains a snapshot of an operating system like Linux with everything configured as it was upon snapshot creation.
[AWS::EC2::Instance]
## Images
Amazon Machine Images (AMI) are prepackaged in numerous ways to meet a legion of use cases. Public images are found within [the AWS console's AMI search feature]. If you have an AWS account, you can access the search feature.
[AWS::ImageBuilder::Image]
## Security Groups
Security groups are a collection of [firewall] rules that secure your instances from nefarious hackers. If you're familiar with firewalls, you will be familiar with security groups. Apply [the principle of least privilege] and only grant access to systems that require access to your EC2 instances.
[AWS::EC2::SecurityGroup]
## Other Concepts
Learn EC2 concepts you'll need to understand when using EC2.
### Key Pairs
Use key pairs to gain [secure shell] access on your EC2 instance.
Create a key pair with this command.
```
key_name=your-key-name
aws ec2 create-key-pair --key-name "${key_name}" | jq -r '.KeyMaterial' >| "${key_name}.pem"
```
### Volumes
Attach disks to your EC2 instances to expand space and meet various use cases like high-performance read/write disk access.
[AWS::EC2::Volume]
### Load Balancers
Scale up your instances by routing traffic to multiple instances.
[AWS::ElasticLoadBalancing::LoadBalancer]
### Snapshots
Create a moment-in-time snapshot of your EC2 instances.
Create a snapshot with this command.
```
aws ec2 create-snapshot --volume-id <VolumeId> --description "My Snapshot"
```
### Capacity Reservations
Save money by reserving your EC2 instances in advance.
## Learn EC2 - Beyond the Basics
- **Books**
- [Programming Amazon Ec2] (O'Reilly)
- **Videos**
- [Amazon EC2 Fundamentals] (LinkedIn)
- [Managing AWS EC2 Instances] (Pluralsight)
{{< partial "category_footer" >}}
[virtual machines]: https://en.wikipedia.org/wiki/Virtual_machine
[amazon lightsail]: https://aws.amazon.com/lightsail/
[launch template]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-launchtemplate.html
[aws::autoscaling::autoscalinggroup]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-group.html
[aws::ec2::instance]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html
[the aws console's ami search feature]: https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#Images:visibility=public-images;sort=name
[aws::imagebuilder::image]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-image.html
[firewall]: https://en.wikipedia.org/wiki/Firewall_(computing)
[the principle of least privilege]: https://en.wikipedia.org/wiki/Principle_of_least_privilege
[aws::ec2::securitygroup]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html
[secure shell]: https://en.wikipedia.org/wiki/Secure_Shell
[aws::ec2::volume]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-ebs-volume.html
[aws::elasticloadbalancing::loadbalancer]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-elb.html
[programming amazon ec2]: https://www.amazon.com/Programming-Amazon-EC2-Survive-Success/dp/1449393683/ref=sr_1_8?dchild=1&keywords=ec2&qid=1594254278&rnid=2941120011&s=books&sr=1-8
[amazon ec2 fundamentals]: https://www.linkedin.com/learning/amazon-ec2-fundamentals-2
[managing aws ec2 instances]: https://app.pluralsight.com/library/courses/aws-managing-ec2-instances/table-of-contents