Show / Hide Table of Contents

Class KeyPairProps

The properties of a Key Pair.

Inheritance
object
KeyPairProps
Implements
IKeyPairProps
IResourceProps
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class KeyPairProps : IKeyPairProps, IResourceProps
Syntax (vb)
Public Class KeyPairProps Implements IKeyPairProps, IResourceProps
Remarks

ExampleMetadata: infused

Examples
Vpc vpc;
            InstanceType instanceType;


            var keyPair = new KeyPair(this, "KeyPair", new KeyPairProps {
                Type = KeyPairType.ED25519,
                Format = KeyPairFormat.PEM
            });
            var instance = new Instance(this, "Instance", new InstanceProps {
                Vpc = vpc,
                InstanceType = instanceType,
                MachineImage = MachineImage.LatestAmazonLinux2023(),
                // Use the custom key pair
                KeyPair = keyPair
            });

Synopsis

Constructors

KeyPairProps()

The properties of a Key Pair.

Properties

Account

The AWS account ID this resource belongs to.

EnvironmentFromArn

ARN to deduce region and account from.

Format

The format of the key pair.

KeyPairName

A unique name for the key pair.

PhysicalName

The value passed in by users to the physical name prop of the resource.

PublicKeyMaterial

The public key material.

Region

The AWS region this resource belongs to.

Type

The type of key pair.

Constructors

KeyPairProps()

The properties of a Key Pair.

public KeyPairProps()
Remarks

ExampleMetadata: infused

Examples
Vpc vpc;
            InstanceType instanceType;


            var keyPair = new KeyPair(this, "KeyPair", new KeyPairProps {
                Type = KeyPairType.ED25519,
                Format = KeyPairFormat.PEM
            });
            var instance = new Instance(this, "Instance", new InstanceProps {
                Vpc = vpc,
                InstanceType = instanceType,
                MachineImage = MachineImage.LatestAmazonLinux2023(),
                // Use the custom key pair
                KeyPair = keyPair
            });

Properties

Account

The AWS account ID this resource belongs to.

public string? Account { get; set; }
Property Value

string

Remarks

Default: - the resource is in the same account as the stack it belongs to

EnvironmentFromArn

ARN to deduce region and account from.

public string? EnvironmentFromArn { get; set; }
Property Value

string

Remarks

The ARN is parsed and the account and region are taken from the ARN. This should be used for imported resources.

Cannot be supplied together with either account or region.

Default: - take environment from account, region parameters, or use Stack environment.

Format

The format of the key pair.

public KeyPairFormat? Format { get; set; }
Property Value

KeyPairFormat?

Remarks

Default: PEM

KeyPairName

A unique name for the key pair.

public string? KeyPairName { get; set; }
Property Value

string

Remarks

Default: A generated name

PhysicalName

The value passed in by users to the physical name prop of the resource.

public string? PhysicalName { get; set; }
Property Value

string

Remarks

    Default: - The physical name will be allocated by CloudFormation at deployment time

    PublicKeyMaterial

    The public key material.

    public string? PublicKeyMaterial { get; set; }
    Property Value

    string

    Remarks

    If this is provided the key is considered "imported". For imported keys, it is assumed that you already have the private key material so the private key material will not be returned or stored in AWS Systems Manager Parameter Store.

    Default: a public and private key will be generated

    Region

    The AWS region this resource belongs to.

    public string? Region { get; set; }
    Property Value

    string

    Remarks

    Default: - the resource is in the same region as the stack it belongs to

    Type

    The type of key pair.

    public KeyPairType? Type { get; set; }
    Property Value

    KeyPairType?

    Remarks

    Default: RSA (ignored if keyMaterial is provided)

    Implements

    IKeyPairProps
    IResourceProps
    Back to top Generated by DocFX