# KeyPairType

The type of the key pair.

- Source: [`aws-ec2/lib/key-pair.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-ec2/lib/key-pair.ts#L31)
- Type last changed: v2.116.0 · 22 Dec 2023

## Example

```ts
declare const vpc: ec2.Vpc;
declare const instanceType: ec2.InstanceType;

const keyPair = new ec2.KeyPair(this, 'KeyPair', {
  type: ec2.KeyPairType.ED25519,
  format: ec2.KeyPairFormat.PEM,
});
const instance = new ec2.Instance(this, 'Instance', {
  vpc,
  instanceType,
  machineImage: ec2.MachineImage.latestAmazonLinux2023(),
  // Use the custom key pair
  keyPair,
});
```

## Members

| Member | Description |
| --- | --- |
| `RSA` | An RSA key. |
| `ED25519` | An ED25519 key. |

## Referenced by

- [`IKeyPair`](/v2/docs/aws-cdk-lib.aws_ec2.IKeyPair).type
- [`KeyPair`](/v2/docs/aws-cdk-lib.aws_ec2.KeyPair).type
- [`KeyPairAttributes`](/v2/docs/aws-cdk-lib.aws_ec2.KeyPairAttributes).type
- [`KeyPairProps`](/v2/docs/aws-cdk-lib.aws_ec2.KeyPairProps).type
