Amazon Elastic Compute Cloud
API Reference (API Version 2011-12-15)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

DescribeKeyPairs

Description

Returns information about key pairs available to you. If you specify key pairs, information about those key pairs is returned. Otherwise, information for all your key pairs is returned.

You can filter the results to return information only about key pairs that match criteria you specify. For example, you could filter the results to return only the key pairs whose names include the string Dave. You can specify multiple values for a filter. A key pair must match at least one of the specified values for it to be included in the results.

You can specify multiple filters (e.g., the key pair name includes the string Dave, and the fingerprint equals a certain value). The result includes information for a particular key pair only if it matches all your filters. If there's no match, no special message is returned; the response is simply empty.

You can use wildcards with the filter values: * matches zero or more characters, and ? matches exactly one character. You can escape special characters using a backslash before the character. For example, a value of \*amazon\?\\ searches for the literal string *amazon?\.

The following table shows the available filters.

Filter Name Description

fingerprint

Fingerprint of the key pair.

Type: String

key-name

Name of the key pair.

Type: String

Request Parameters

NameDescriptionRequired

KeyName.n

One or more key pair names.

Type: String

Default: Describes all key pairs you own, or only those otherwise specified.

No

Filter.n.Name

Name of a filter. See the preceding table for a list of allowed filter names.

Type: String

Default: None

No

Filter.n.Value.m

A value for the filter. See the preceding table for a list of allowed values for each filter.

Type: String

Default: None

No

Response Elements

The elements in the following table are wrapped in a DescribeKeyPairsResponse structure.

NameDescription

requestId

The ID of the request.

Type: xsd:string

keySet

List of key pairs. Each key pair's information is wrapped in an item element.

Type: DescribeKeyPairsResponseItemType

Examples

Example Request

This example describes the keypair with name gsg-keypair.

https://ec2.amazonaws.com/?Action=DescribeKeyPairs
&KeyName.1=gsg-keypair
&AUTHPARAMS

Example Response

<DescribeKeyPairsResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
    <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> 
    <keySet>
      <item>
         <keyName>gsg-keypair</keyName>
         <keyFingerprint>
         1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f
         </keyFingerprint>
      </item>
   </keySet>
</DescribeKeyPairsResponse>

Example Request

This example filters the results to display only key pairs whose names include the string Dave.

https://ec2.amazonaws.com/?Action=DescribeKeyPairs
&Filter.1.Name=key-name
&Filter.1.Value.1=*Dave*
&AUTHPARAMS