# CfnKeyPairProps

Properties for defining a `CfnKeyPair`.

Used as props by: [CfnKeyPair](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.CfnKeyPair.html)

- Source: Generated at build time
- Type last changed: v2.88.0 · 20 Jul 2023

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
const cfnKeyPairProps: ec2.CfnKeyPairProps = {
  keyName: 'keyName',

  // the properties below are optional
  keyFormat: 'keyFormat',
  keyType: 'keyType',
  publicKeyMaterial: 'publicKeyMaterial',
  tags: [{
    key: 'key',
    value: 'value',
  }],
};
```

Python:

```python
from aws_cdk import CfnTag
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ec2 as ec2

cfn_key_pair_props = ec2.CfnKeyPairProps(
    key_name="keyName",

    # the properties below are optional
    key_format="keyFormat",
    key_type="keyType",
    public_key_material="publicKeyMaterial",
    tags=[CfnTag(
        key="key",
        value="value"
    )]
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ec2.*;

CfnKeyPairProps cfnKeyPairProps = CfnKeyPairProps.builder()
        .keyName("keyName")

        // the properties below are optional
        .keyFormat("keyFormat")
        .keyType("keyType")
        .publicKeyMaterial("publicKeyMaterial")
        .tags(List.of(CfnTag.builder()
                .key("key")
                .value("value")
                .build()))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.EC2;

var cfnKeyPairProps = new CfnKeyPairProps {
    KeyName = "keyName",

    // the properties below are optional
    KeyFormat = "keyFormat",
    KeyType = "keyType",
    PublicKeyMaterial = "publicKeyMaterial",
    Tags = new [] { new CfnTag {
        Key = "key",
        Value = "value"
    } }
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

cfnKeyPairProps := &CfnKeyPairProps{
	KeyName: jsii.String("keyName"),

	// the properties below are optional
	KeyFormat: jsii.String("keyFormat"),
	KeyType: jsii.String("keyType"),
	PublicKeyMaterial: jsii.String("publicKeyMaterial"),
	Tags: []CfnTag{
		&CfnTag{
			Key: jsii.String("key"),
			Value: jsii.String("value"),
		},
	},
}
```

## Properties

- `keyFormat`: string = "pem" — The format of the key pair.

  Default: `pem`

- `keyName`: string (required) — A unique name for the key pair.

  Constraints: Up to 255 ASCII characters

- `keyType`: string = "rsa" — The type of key pair. Note that ED25519 keys are not supported for Windows instances.

  If the `PublicKeyMaterial` property is specified, the `KeyType` property is ignored, and the key type is inferred from the `PublicKeyMaterial` value.

  Default: `rsa`

- `publicKeyMaterial`: string — The public key material.

  The `PublicKeyMaterial` property is used to import a key pair. If this property is not specified, then a new key pair will be created.

- `tags`: [CfnTag](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CfnTag.html)[] — The tags to apply to the key pair.
