key_pairs
Creates, updates, deletes, gets or lists a key_pairs resource.
Overview
| Name | key_pairs |
| Type | Resource |
| Id | aws.ec2.key_pairs |
Fields
The following fields are returned by SELECT queries:
- describe_key_pairs
| Name | Datatype | Description |
|---|---|---|
create_time | string | If you used Amazon EC2 to create the key pair, this is the date and time when the key was created, in ISO 8601 date-time format, in the UTC time zone. If you imported an existing key pair to Amazon EC2, this is the date and time the key was imported, in ISO 8601 date-time format, in the UTC time zone. |
key_fingerprint | string | If you used CreateKeyPair to create the key pair: For RSA key pairs, the key fingerprint is the SHA-1 digest of the DER encoded private key. For ED25519 key pairs, the key fingerprint is the base64-encoded SHA-256 digest, which is the default for OpenSSH, starting with OpenSSH 6.8. If you used ImportKeyPair to provide Amazon Web Services the public key: For RSA key pairs, the key fingerprint is the MD5 public key fingerprint as specified in section 4 of RFC4716. For ED25519 key pairs, the key fingerprint is the base64-encoded SHA-256 digest, which is the default for OpenSSH, starting with OpenSSH 6.8. |
key_name | string | The name of the key pair. |
key_pair_id | string | The ID of the key pair. |
key_type | string | The type of key pair. |
public_key | string | The public key material. |
tags | string | Any tags applied to the key pair. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
describe_key_pairs | select | region | KeyName, KeyPairId, IncludePublicKey, DryRun, Filter | 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 EC2 User Guide. |
create_key_pair | insert | KeyName, region | KeyType, TagSpecification, KeyFormat, DryRun | Creates an ED25519 or 2048-bit RSA key pair with the specified name and in the specified format. Amazon EC2 stores the public key and displays the private key for you to save to a file. The private key is returned as an unencrypted PEM encoded PKCS#1 private key or an unencrypted PPK formatted private key for use with PuTTY. If a key with the specified name already exists, Amazon EC2 returns an error. The key pair returned to you is available only in the Amazon Web Services Region in which you create it. If you prefer, you can create your own key pair using a third-party tool and upload it to any Region using ImportKeyPair. You can have up to 5,000 key pairs per Amazon Web Services Region. For more information, see Amazon EC2 key pairs in the Amazon EC2 User Guide. |
delete_key_pair | delete | region | KeyName, KeyPairId, DryRun | Deletes the specified key pair, by removing the public key from Amazon EC2. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
KeyName | string | A unique name for the key pair. Constraints: Up to 255 ASCII characters |
region | string | AWS region (default: us-east-1) |
DryRun | boolean | Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation. |
Filter | array | The filters. key-pair-id - The ID of the key pair. fingerprint - The fingerprint of the key pair. key-name - The name of the key pair. tag-key - The key of a tag assigned to the resource. Use this filter to find all resources assigned a tag with a specific key, regardless of the tag value. tag:<key> - The key/value combination of a tag assigned to the resource. Use the tag key in the filter name and the tag value as the filter value. For example, to find all resources that have a tag with the key Owner and the value TeamA, specify tag:Owner for the filter name and TeamA for the filter value. |
IncludePublicKey | boolean | If true, the public key material is included in the response. Default: false |
KeyFormat | string | The format of the key pair. Default: pem |
KeyName | string | The name of the key pair. |
KeyPairId | string | The ID of the key pair. |
KeyType | string | The type of key pair. Note that ED25519 keys are not supported for Windows instances. Default: rsa |
TagSpecification | array | The tags to apply to the new key pair. |
SELECT examples
- describe_key_pairs
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 EC2 User Guide.
SELECT
create_time,
key_fingerprint,
key_name,
key_pair_id,
key_type,
public_key,
tags
FROM aws.ec2.key_pairs
WHERE region = '{{ region }}' -- required
AND KeyName = '{{ KeyName }}'
AND KeyPairId = '{{ KeyPairId }}'
AND IncludePublicKey = '{{ IncludePublicKey }}'
AND DryRun = '{{ DryRun }}'
AND Filter = '{{ Filter }}'
;
INSERT examples
- create_key_pair
- Manifest
Creates an ED25519 or 2048-bit RSA key pair with the specified name and in the specified format. Amazon EC2 stores the public key and displays the private key for you to save to a file. The private key is returned as an unencrypted PEM encoded PKCS#1 private key or an unencrypted PPK formatted private key for use with PuTTY. If a key with the specified name already exists, Amazon EC2 returns an error. The key pair returned to you is available only in the Amazon Web Services Region in which you create it. If you prefer, you can create your own key pair using a third-party tool and upload it to any Region using ImportKeyPair. You can have up to 5,000 key pairs per Amazon Web Services Region. For more information, see Amazon EC2 key pairs in the Amazon EC2 User Guide.
INSERT INTO aws.ec2.key_pairs (
KeyName,
region,
KeyType,
TagSpecification,
KeyFormat,
DryRun
)
SELECT
'{{ KeyName }}',
'{{ region }}',
'{{ KeyType }}',
'{{ TagSpecification }}',
'{{ KeyFormat }}',
'{{ DryRun }}'
RETURNING
key_fingerprint,
key_material,
key_name,
key_pair_id,
tags
;
# Description fields are for documentation purposes
- name: key_pairs
props:
- name: KeyName
value: "{{ KeyName }}"
description: Required parameter for the key_pairs resource.
- name: region
value: "{{ region }}"
description: Required parameter for the key_pairs resource.
- name: KeyType
value: "{{ KeyType }}"
description: The type of key pair. Note that ED25519 keys are not supported for Windows instances. Default: rsa
description: The type of key pair. Note that ED25519 keys are not supported for Windows instances. Default: rsa
- name: TagSpecification
value: "{{ TagSpecification }}"
description: The tags to apply to the new key pair.
description: The tags to apply to the new key pair.
- name: KeyFormat
value: "{{ KeyFormat }}"
description: The format of the key pair. Default: pem
description: The format of the key pair. Default: pem
- name: DryRun
value: {{ DryRun }}
description: Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.
description: Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.
DELETE examples
- delete_key_pair
Deletes the specified key pair, by removing the public key from Amazon EC2.
DELETE FROM aws.ec2.key_pairs
WHERE region = '{{ region }}' --required
AND KeyName = '{{ KeyName }}'
AND KeyPairId = '{{ KeyPairId }}'
AND DryRun = '{{ DryRun }}'
;