Class CfnKeyPair
- All Implemented Interfaces:
IConstruct
,IDependable
,IInspectable
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
AWS::EC2::KeyPair
.
Specifies a key pair for use with an Amazon Elastic Compute Cloud instance as follows:
- 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 .keyType("keyType") .publicKeyMaterial("publicKeyMaterial") .tags(List.of(CfnTag.builder() .key("key") .value("value") .build())) .build();
-
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.amazon.awscdk.core.IConstruct
IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The CloudFormation resource type name for this resource class. -
Constructor Summary
ModifierConstructorDescriptionCfnKeyPair
(Construct scope, String id, CfnKeyPairProps props) Create a newAWS::EC2::KeyPair
.protected
CfnKeyPair
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
CfnKeyPair
(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionIf you created the key pair using Amazon EC2:.The ID of the key pair.A unique name for the key pair.The type of key pair.The public key material.getTags()
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
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.Methods inherited from class software.amazon.awscdk.core.CfnResource
addDeletionOverride, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, isCfnResource, shouldSynthesize, toString, validateProperties
Methods inherited from class software.amazon.awscdk.core.CfnRefElement
getRef
Methods inherited from class software.amazon.awscdk.core.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
Methods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
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 Construct scope, @NotNull String id, @NotNull CfnKeyPairProps props) Create a newAWS::EC2::KeyPair
.- Parameters:
scope
-- scope in which this resource is defined.
id
-- scoped id of the resource.
props
-- resource properties.
-
-
Method Details
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspect
in interfaceIInspectable
- Parameters:
inspector
-- tree inspector to collect and process attributes.
-
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
The tags to apply to the key pair. -
getKeyName
A unique name for the key pair.Constraints: Up to 255 ASCII characters
-
setKeyName
A unique name for the key pair.Constraints: Up to 255 ASCII characters
-
getKeyType
The type of key pair. Note that ED25519 keys are not supported for Windows instances.If the
PublicKeyMaterial
property is specified, theKeyType
property is ignored, and the key type is inferred from thePublicKeyMaterial
value.Default:
rsa
-
setKeyType
The type of key pair. Note that ED25519 keys are not supported for Windows instances.If the
PublicKeyMaterial
property is specified, theKeyType
property is ignored, and the key type is inferred from thePublicKeyMaterial
value.Default:
rsa
-
getPublicKeyMaterial
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. -
setPublicKeyMaterial
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.
-