interface KeyPairProps
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.EC2.KeyPairProps |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsec2#KeyPairProps |
Java | software.amazon.awscdk.services.ec2.KeyPairProps |
Python | aws_cdk.aws_ec2.KeyPairProps |
TypeScript (source) | aws-cdk-lib » aws_ec2 » KeyPairProps |
The properties of a Key Pair.
Example
declare const vpc: ec2.Vpc;
declare const instanceType: ec2.InstanceType;
const keyPair = new ec2.KeyPair(this, 'KeyPair', {
type: ec2.KeyPairType.ED25519,
format: ec2.KeyPairFormat.PEM,
});
const instance = new ec2.Instance(this, 'Instance', {
vpc,
instanceType,
machineImage: ec2.MachineImage.latestAmazonLinux2023(),
// Use the custom key pair
keyPair,
});
Properties
Name | Type | Description |
---|---|---|
account? | string | The AWS account ID this resource belongs to. |
environment | string | ARN to deduce region and account from. |
format? | Key | The format of the key pair. |
key | string | A unique name for the key pair. |
physical | string | The value passed in by users to the physical name prop of the resource. |
public | string | The public key material. |
region? | string | The AWS region this resource belongs to. |
type? | Key | The type of key pair. |
account?
Type:
string
(optional, default: the resource is in the same account as the stack it belongs to)
The AWS account ID this resource belongs to.
environmentFromArn?
Type:
string
(optional, default: take environment from account
, region
parameters, or use Stack environment.)
ARN to deduce region and account from.
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
.
format?
Type:
Key
(optional, default: PEM)
The format of the key pair.
keyPairName?
Type:
string
(optional, default: A generated name)
A unique name for the key pair.
physicalName?
Type:
string
(optional, default: The physical name will be allocated by CloudFormation at deployment time)
The value passed in by users to the physical name prop of the resource.
undefined
implies that a physical name will be allocated by CloudFormation during deployment.- a concrete value implies a specific physical name
PhysicalName.GENERATE_IF_NEEDED
is a marker that indicates that a physical will only be generated by the CDK if it is needed for cross-environment references. Otherwise, it will be allocated by CloudFormation.
publicKeyMaterial?
Type:
string
(optional, default: a public and private key will be generated)
The public key material.
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.
region?
Type:
string
(optional, default: the resource is in the same region as the stack it belongs to)
The AWS region this resource belongs to.
type?
Type:
Key
(optional, default: RSA (ignored if keyMaterial is provided))
The type of key pair.