

# The Amazon EC2 instances for your Elastic Beanstalk environment
<a name="using-features.managing.ec2"></a>

This topic explains the Amazon EC2 instances and the configuration options that affect your Elastic Beanstalk environment.

When you create a web server environment, AWS Elastic Beanstalk creates one or more Amazon Elastic Compute Cloud (Amazon EC2) virtual machines, known as *Instances*.

The instances in your environment are configured to run web apps on the platform that you choose. You can make changes to various properties and behaviors of your environment's instances when you create your environment or after it's already running. Or, you can already make these changes by modifying the source code that you deploy to the environment. For for more information, see [Configuration options](command-options.md).

**Note**  
The [Auto Scaling group](using-features.managing.as.md) in your environment manages the Amazon EC2 instances that run your application. When you make configuration changes that are described in this topic, the launch configuration also changes. The launch configuration is either an Amazon EC2 launch template or an Auto Scaling group launch configuration resource. This change requires [replacement of all instances](environments-updating.md). It also triggers either a [rolling update](using-features.rollingupdates.md) or [immutable update](environmentmgmt-updates-immutable.md), depending on which one is configured.

**EC2 instance purchasing options**  
Elastic Beanstalk supports several Amazon EC2 [instance purchasing options](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-purchasing-options.html):
+ **On-Demand** — An *On-Demand Instance *is a pay-as-you-go resource—there's no long-term commitment required when you use it.
+ **Reserved** — A *Reserved Instance *is a pre-purchased billing discount applied automatically to matching On-Demand instances in your environment.
+ **Spot** — A *Spot Instance *is an unused Amazon EC2 instance that is available for less than the On-Demand price. You can enable and configure the allocation of Spot Instances in your environment. For more information, see [Auto Scaling your Elastic Beanstalk environment instances](using-features.managing.as.md).

**Topics**
+ [Amazon EC2 instance types](using-features.managing.ec2.instance-types.md)
+ [Configuring Amazon EC2 instances using the Elastic Beanstalk console](using-features.managing.ec2.console.md)
+ [Managing EC2 security groups](using-features.managing.ec2.instances.sg.md)
+ [EC2 key pair](#using-features.managing.security.keypair)
+ [Configuring Amazon EC2 security groups and instance types using the AWS CLI](using-features.managing.ec2.aws-cli.md)
+ [Configuring Amazon EC2 instances with namespace options](using-features.managing.ec2.namespace.md)
+ [Configuring the IMDS on your Elastic Beanstalk environment's instances](environments-cfg-ec2-imds.md)

## EC2 key pair
<a name="using-features.managing.security.keypair"></a>

You can securely log in to the Amazon Elastic Compute Cloud (Amazon EC2) instances provisioned for your Elastic Beanstalk application with an Amazon EC2 key pair. For instructions on creating a key pair, see [Creating a Key Pair Using Amazon EC2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#having-ec2-create-your-key-pair) in the *Amazon EC2 User Guide*. 

**Note**  
When you create a key pair, Amazon EC2 stores a copy of your public key. If you no longer need to use it to connect to any environment instances, you can delete it from Amazon EC2. For details, see [Deleting Your Key Pair](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#delete-key-pair) in the *Amazon EC2 User Guide*.

Choose an **EC2 key pair** from the drop-down menu to assign it to your environment's instances. When you assign a key pair, the public key is stored on the instance to authenticate the private key, which you store locally. The private key is never stored on AWS.

For more information about connecting to Amazon EC2 instances, see [Connect to Your Instance](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstances.html) and [Connecting to Linux/UNIX Instances from Windows using PuTTY](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html) in the *Amazon EC2 User Guide*. 