Class KeyPairProps
The properties of a Key Pair.
Inheritance
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class KeyPairProps : Object, IKeyPairProps, IResourceProps
Syntax (vb)
Public Class KeyPairProps
Inherits Object
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
Key |
Properties
Account | The AWS account ID this resource belongs to. |
Environment |
ARN to deduce region and account from. |
Format | The format of the key pair. |
Key |
A unique name for the key pair. |
Physical |
The value passed in by users to the physical name prop of the resource. |
Public |
The public key material. |
Region | The AWS region this resource belongs to. |
Type | The type of key pair. |
Constructors
KeyPairProps()
public KeyPairProps()
Properties
Account
The AWS account ID this resource belongs to.
public string Account { get; set; }
Property Value
System.
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
System.
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 Nullable<KeyPairFormat> Format { get; set; }
Property Value
System.
Remarks
Default: PEM
KeyPairName
A unique name for the key pair.
public string KeyPairName { get; set; }
Property Value
System.
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
System.
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
System.
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
System.
Remarks
Default: - the resource is in the same region as the stack it belongs to
Type
The type of key pair.
public Nullable<KeyPairType> Type { get; set; }
Property Value
System.
Remarks
Default: RSA (ignored if keyMaterial is provided)