# KeyPairAttributes

Attributes of a Key Pair.

Used as argument in: [KeyPair.fromKeyPairAttributes](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.KeyPair.html#fromkeypairattributes)

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

## Example

TypeScript:

```ts
const keyPair = ec2.KeyPair.fromKeyPairAttributes(this, 'KeyPair', {
  keyPairName: 'the-keypair-name',
  type: ec2.KeyPairType.RSA,
})
```

Python:

```python
key_pair = ec2.KeyPair.from_key_pair_attributes(self, "KeyPair",
    key_pair_name="the-keypair-name",
    type=ec2.KeyPairType.RSA
)
```

Java:

```java
IKeyPair keyPair = KeyPair.fromKeyPairAttributes(this, "KeyPair", KeyPairAttributes.builder()
        .keyPairName("the-keypair-name")
        .type(KeyPairType.RSA)
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var keyPair = KeyPair.FromKeyPairAttributes(this, "KeyPair", new KeyPairAttributes {
    KeyPairName = "the-keypair-name",
    Type = KeyPairType.RSA
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
keyPair := ec2.KeyPair_FromKeyPairAttributes(this, jsii.String("KeyPair"), &KeyPairAttributes{
	KeyPairName: jsii.String("the-keypair-name"),
	Type: ec2.KeyPairType_RSA,
})
```

## Properties

- `keyPairName`: string (required) — The unique name of the key pair.

- `type`: [KeyPairType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.KeyPairType.html) — The type of the key pair.

  **Default:** no type specified
