Skip to content
v2.278.0

CfnKeyPairProps Struct ​

Properties for defining a CfnKeyPair.

Example ​

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
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
// 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();
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"
    } }
};
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 ​

keyFormatoptionalstringkey_formatoptionalstrkeyFormatoptionalStringKeyFormatoptionalstringKeyFormatoptional*string = "pem" #
The format of the key pair.

Default: pem

keyNamestringkey_namestrkeyNameStringKeyNamestringKeyName*string required #
A unique name for the key pair.

Constraints: Up to 255 ASCII characters

keyTypeoptionalstringkey_typeoptionalstrkeyTypeoptionalStringKeyTypeoptionalstringKeyTypeoptional*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

publicKeyMaterialoptionalstringpublic_key_materialoptionalstrpublicKeyMaterialoptionalStringPublicKeyMaterialoptionalstringPublicKeyMaterialoptional*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.

tagsoptionalCfnTag[]tagsoptionaltyping.List[CfnTag]tagsoptionalList<CfnTag>TagsoptionalCfnTag[]Tagsoptional*[]CfnTag #
The tags to apply to the key pair.