Class CfnKeyPair
- All Implemented Interfaces:
IInspectable,IKeyPairRef,IEnvironmentAware,ITaggable,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
- To import an existing key pair, include the
PublicKeyMaterialproperty. - To create a new key pair, omit the
PublicKeyMaterialproperty.
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 CloudFormation in the Amazon EC2 User Guide .
When 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 ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.interfaces.ec2.IKeyPairRef
IKeyPairRef.Jsii$Default, IKeyPairRef.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.ITaggable
ITaggable.Jsii$Default, ITaggable.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCfnKeyPair(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnKeyPair(software.amazon.jsii.JsiiObjectRef objRef) CfnKeyPair(software.constructs.Construct scope, String id, CfnKeyPairProps props) Create a newAWS::EC2::KeyPair. -
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.A reference to a KeyPair resource.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.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.static BooleanChecks whether the given object is a CfnKeyPair.renderProperties(Map<String, Object> props) voidsetKeyFormat(String value) The format of the key pair.voidsetKeyName(String value) A unique name for the key pair.voidsetKeyType(String value) The type of key pair.voidsetPublicKeyMaterial(String value) The public key material.voidsetTagsRaw(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, getEnv, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validatePropertiesMethods inherited from class software.amazon.awscdk.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.constructs.Construct
getNode, isConstructMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.interfaces.IEnvironmentAware
getEnvMethods 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) Create a newAWS::EC2::KeyPair.- 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
-
isCfnKeyPair
Checks whether the given object is a CfnKeyPair.- Parameters:
x- This parameter is required.
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspectin 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:
renderPropertiesin 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:
getCfnPropertiesin classCfnResource
-
getKeyPairRef
A reference to a KeyPair resource.- Specified by:
getKeyPairRefin interfaceIKeyPairRef
-
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.
-