We are excited to announce our new API Documentation.
Protected
Describes the specified key pairs or all of your key pairs.
For more information about key pairs, see Amazon EC2 key pairs in the Amazon Elastic Compute Cloud User Guide.
Use a bare-bones client and the command you need to make an API call.
import { EC2Client, DescribeKeyPairsCommand } from "@aws-sdk/client-ec2"; // ES Modules import// const { EC2Client, DescribeKeyPairsCommand } = require("@aws-sdk/client-ec2"); // CommonJS importconst client = new EC2Client(config);const input = { // DescribeKeyPairsRequest Filters: [ // FilterList { // Filter Name: "STRING_VALUE", Values: [ // ValueStringList "STRING_VALUE", ], }, ], KeyNames: [ // KeyNameStringList "STRING_VALUE", ], KeyPairIds: [ // KeyPairIdStringList "STRING_VALUE", ], DryRun: true || false, IncludePublicKey: true || false,};const command = new DescribeKeyPairsCommand(input);const response = await client.send(command);// { // DescribeKeyPairsResult// KeyPairs: [ // KeyPairList// { // KeyPairInfo// KeyPairId: "STRING_VALUE",// KeyFingerprint: "STRING_VALUE",// KeyName: "STRING_VALUE",// KeyType: "rsa" || "ed25519",// Tags: [ // TagList// { // Tag// Key: "STRING_VALUE",// Value: "STRING_VALUE",// },// ],// PublicKey: "STRING_VALUE",// CreateTime: new Date("TIMESTAMP"),// },// ],// };
DescribeKeyPairsCommandInput
DescribeKeyPairsCommandOutput
input
response
config
EC2ServiceException
Base exception class for all service exceptions from EC2 service.
To display a key pair
// This example displays the fingerprint for the specified key.const input = { "KeyNames": [ "my-key-pair" ]};const command = new DescribeKeyPairsCommand(input);const response = await client.send(command);/* response =={ "KeyPairs": [ { "KeyFingerprint": "1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f", "KeyName": "my-key-pair" } ]}*/// example id: ec2-describe-key-pairs-1
Readonly
Static
Describes the specified key pairs or all of your key pairs.
For more information about key pairs, see Amazon EC2 key pairs in the Amazon Elastic Compute Cloud User Guide.
Example
Use a bare-bones client and the command you need to make an API call.
Param
DescribeKeyPairsCommandInput
Returns
DescribeKeyPairsCommandOutput
See
input
shape.response
shape.config
shape.Throws
EC2ServiceException
Base exception class for all service exceptions from EC2 service.
Example
To display a key pair