Class CfnKeyPair
- All Implemented Interfaces:
IInspectable
,ITaggable
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
- To import an existing key pair, include the
PublicKeyMaterial
property. - To create a new key pair, omit the
PublicKeyMaterial
property.
When you import an existing key pair, you specify the public key material for the key. We assume that you have the private key material for the key. AWS CloudFormation does not create or return the private key material when you import a key pair.
When you create a new key pair, the private key is saved to AWS Systems Manager Parameter Store, using a parameter with the following name: /ec2/keypair/{key_pair_id}
. For more information about retrieving private key, and the required permissions, see Create a key pair using AWS CloudFormation in the Amazon EC2 User Guide .
When AWS CloudFormation deletes a key pair that was created or imported by a stack, it also deletes the parameter that was used to store the private key material in Parameter Store.
Example:
// 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.*; CfnKeyPair cfnKeyPair = CfnKeyPair.Builder.create(this, "MyCfnKeyPair") .keyName("keyName") // the properties below are optional .keyFormat("keyFormat") .keyType("keyType") .publicKeyMaterial("publicKeyMaterial") .tags(List.of(CfnTag.builder() .key("key") .value("value") .build())) .build();
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
Nested classes/interfaces inherited from interface software.amazon.awscdk.ITaggable
ITaggable.Jsii$Default, ITaggable.Jsii$Proxy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The CloudFormation resource type name for this resource class. -
Constructor Summary
ModifierConstructorDescriptionprotected
CfnKeyPair
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
CfnKeyPair
(software.amazon.jsii.JsiiObjectRef objRef) CfnKeyPair
(software.constructs.Construct scope, String id, CfnKeyPairProps props) -
Method Summary
Modifier and TypeMethodDescriptionIf you created the key pair using Amazon EC2:.The ID of the key pair.The format of the key pair.A unique name for the key pair.The type of key pair.The public key material.getTags()
Tag Manager which manages the tags for this resource.The tags to apply to the key pair.void
inspect
(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties
(Map<String, Object> props) void
setKeyFormat
(String value) The format of the key pair.void
setKeyName
(String value) A unique name for the key pair.void
setKeyType
(String value) The type of key pair.void
setPublicKeyMaterial
(String value) The public key material.void
setTagsRaw
(List<CfnTag> value) The tags to apply to the key pair.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validateProperties
Methods inherited from class software.amazon.awscdk.CfnRefElement
getRef
Methods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
Methods inherited from class software.constructs.Construct
getNode, isConstruct
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnKeyPair
protected CfnKeyPair(software.amazon.jsii.JsiiObjectRef objRef) -
CfnKeyPair
protected CfnKeyPair(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnKeyPair
@Stability(Stable) public CfnKeyPair(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnKeyPairProps props) - Parameters:
scope
- Scope in which this resource is defined. This parameter is required.id
- Construct identifier for this resource (unique in its scope). This parameter is required.props
- Resource properties. This parameter is required.
-
-
Method Details
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspect
in interfaceIInspectable
- Parameters:
inspector
- tree inspector to collect and process attributes. This parameter is required.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderProperties
in classCfnResource
- Parameters:
props
- This parameter is required.
-
getAttrKeyFingerprint
If you created the key pair using Amazon EC2:.- For RSA key pairs, the key fingerprint is the SHA-1 digest of the DER encoded private key.
- For ED25519 key pairs, the key fingerprint is the base64-encoded SHA-256 digest, which is the default for OpenSSH, starting with OpenSSH 6.8 .
If you imported the key pair to Amazon EC2:
- For RSA key pairs, the key fingerprint is the MD5 public key fingerprint as specified in section 4 of RFC 4716.
- For ED25519 key pairs, the key fingerprint is the base64-encoded SHA-256 digest, which is the default for OpenSSH, starting with OpenSSH 6.8 .
-
getAttrKeyPairId
The ID of the key pair. -
getCfnProperties
- Overrides:
getCfnProperties
in classCfnResource
-
getTags
Tag Manager which manages the tags for this resource. -
getKeyName
A unique name for the key pair. -
setKeyName
A unique name for the key pair. -
getKeyFormat
The format of the key pair. -
setKeyFormat
The format of the key pair. -
getKeyType
The type of key pair.Note that ED25519 keys are not supported for Windows instances.
-
setKeyType
The type of key pair.Note that ED25519 keys are not supported for Windows instances.
-
getPublicKeyMaterial
The public key material. -
setPublicKeyMaterial
The public key material. -
getTagsRaw
The tags to apply to the key pair. -
setTagsRaw
The tags to apply to the key pair.
-