Class CfnKeyPairPropsMixin

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.mixins.preview.core.Mixin
software.amazon.awscdk.mixins.preview.services.ec2.mixins.CfnKeyPairPropsMixin
All Implemented Interfaces:
IMixin, software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.121.0 (build d7af9b9)", date="2025-12-18T18:20:25.215Z") @Stability(Stable) public class CfnKeyPairPropsMixin extends Mixin implements IMixin
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 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.mixins.preview.mixins.*;
 import software.amazon.awscdk.mixins.preview.services.ec2.mixins.*;
 CfnKeyPairPropsMixin cfnKeyPairPropsMixin = CfnKeyPairPropsMixin.Builder.create(CfnKeyPairMixinProps.builder()
         .keyFormat("keyFormat")
         .keyName("keyName")
         .keyType("keyType")
         .publicKeyMaterial("publicKeyMaterial")
         .tags(List.of(CfnTag.builder()
                 .key("key")
                 .value("value")
                 .build()))
         .build())
 .strategy(PropertyMergeStrategy.OVERRIDE)
 .build();
 

See Also:
  • Field Details

    • CFN_PROPERTY_KEYS

      @Stability(Stable) protected static final List<String> CFN_PROPERTY_KEYS
  • Constructor Details

    • CfnKeyPairPropsMixin

      protected CfnKeyPairPropsMixin(software.amazon.jsii.JsiiObjectRef objRef)
    • CfnKeyPairPropsMixin

      protected CfnKeyPairPropsMixin(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • CfnKeyPairPropsMixin

      @Stability(Stable) public CfnKeyPairPropsMixin(@NotNull CfnKeyPairMixinProps props, @Nullable CfnPropertyMixinOptions options)
      Create a mixin to apply properties to AWS::EC2::KeyPair.

      Parameters:
      props - L1 properties to apply. This parameter is required.
      options - Mixin options.
    • CfnKeyPairPropsMixin

      @Stability(Stable) public CfnKeyPairPropsMixin(@NotNull CfnKeyPairMixinProps props)
      Create a mixin to apply properties to AWS::EC2::KeyPair.

      Parameters:
      props - L1 properties to apply. This parameter is required.
  • Method Details

    • applyTo

      @Stability(Stable) @NotNull public software.constructs.IConstruct applyTo(@NotNull software.constructs.IConstruct construct)
      Apply the mixin properties to the construct.

      Specified by:
      applyTo in interface IMixin
      Specified by:
      applyTo in class Mixin
      Parameters:
      construct - This parameter is required.
    • supports

      @Stability(Stable) @NotNull public Boolean supports(@NotNull software.constructs.IConstruct construct)
      Check if this mixin supports the given construct.

      Specified by:
      supports in interface IMixin
      Overrides:
      supports in class Mixin
      Parameters:
      construct - This parameter is required.
    • getProps

      @Stability(Stable) @NotNull protected CfnKeyPairMixinProps getProps()
    • getStrategy

      @Stability(Stable) @NotNull protected PropertyMergeStrategy getStrategy()