key_pairs
Creates, updates, deletes, gets or lists a key_pairs resource.
Overview
| Name | key_pairs |
| Type | Resource |
| Id | aws.lightsail.key_pairs |
Fields
The following fields are returned by SELECT queries:
- get_key_pair
- get_key_pairs
| Name | Datatype | Description |
|---|---|---|
name | string | The friendly name of the SSH key pair. (pattern: <code>\w[\w-]*\w</code>) |
arn | string | The Amazon Resource Name (ARN) of the key pair (arn:aws:lightsail:us-east-2:123456789101:KeyPair/05859e3d-331d-48ba-9034-12345EXAMPLE). (pattern: <code>.\S.</code>) |
created_at | string (date-time) | The timestamp when the key pair was created (1479816991.349). |
fingerprint | string | The RSA fingerprint of the key pair. |
location | object | The region name and Availability Zone where the key pair was created. |
resource_type | string | The resource type (usually KeyPair). (ContainerService, Instance, StaticIp, KeyPair, InstanceSnapshot, Domain, PeeredVpc, LoadBalancer, LoadBalancerTlsCertificate, Disk, DiskSnapshot, RelationalDatabase, RelationalDatabaseSnapshot, ExportSnapshotRecord, CloudFormationStackRecord, Alarm, ContactMethod, Distribution, Certificate, Bucket) |
support_code | string | The support code. Include this code in your email to support when you have questions about an instance or another resource in Lightsail. This code enables our support team to look up your Lightsail information more easily. |
tags | array | The tag keys and optional values for the resource. For more information about tags in Lightsail, see the Amazon Lightsail Developer Guide. |
| Name | Datatype | Description |
|---|---|---|
name | string | The friendly name of the SSH key pair. (pattern: <code>\w[\w-]*\w</code>) |
arn | string | The Amazon Resource Name (ARN) of the key pair (arn:aws:lightsail:us-east-2:123456789101:KeyPair/05859e3d-331d-48ba-9034-12345EXAMPLE). (pattern: <code>.\S.</code>) |
created_at | string (date-time) | The timestamp when the key pair was created (1479816991.349). |
fingerprint | string | The RSA fingerprint of the key pair. |
location | object | The region name and Availability Zone where the key pair was created. |
resource_type | string | The resource type (usually KeyPair). (ContainerService, Instance, StaticIp, KeyPair, InstanceSnapshot, Domain, PeeredVpc, LoadBalancer, LoadBalancerTlsCertificate, Disk, DiskSnapshot, RelationalDatabase, RelationalDatabaseSnapshot, ExportSnapshotRecord, CloudFormationStackRecord, Alarm, ContactMethod, Distribution, Certificate, Bucket) |
support_code | string | The support code. Include this code in your email to support when you have questions about an instance or another resource in Lightsail. This code enables our support team to look up your Lightsail information more easily. |
tags | array | The tag keys and optional values for the resource. For more information about tags in Lightsail, see the Amazon Lightsail Developer Guide. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_key_pair | select | region | Returns information about a specific key pair. | |
get_key_pairs | select | region | Returns information about all key pairs in the user's account. | |
create_key_pair | insert | region, keyPairName | Creates a custom SSH key pair that you can use with an Amazon Lightsail instance. Use the DownloadDefaultKeyPair action to create a Lightsail default key pair in an Amazon Web Services Region where a default key pair does not currently exist. The create key pair operation supports tag-based access control via request tags. For more information, see the Amazon Lightsail Developer Guide. | |
delete_key_pair | delete | region | Deletes the specified key pair by removing the public key from Amazon Lightsail. You can delete key pairs that were created using the ImportKeyPair and CreateKeyPair actions, as well as the Lightsail default key pair. A new default key pair will not be created unless you launch an instance without specifying a custom key pair, or you call the DownloadDefaultKeyPair API. The delete key pair operation supports tag-based access control via resource tags applied to the resource identified by key pair name. For more information, see the Amazon Lightsail Developer Guide. | |
import_key_pair | exec | region, keyPairName, publicKeyBase64 | Imports a public SSH key from a specific key pair. |
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 |
|---|---|---|
region | string | AWS region (default: us-east-1) |
SELECT examples
- get_key_pair
- get_key_pairs
Returns information about a specific key pair.
SELECT
name,
arn,
created_at,
fingerprint,
location,
resource_type,
support_code,
tags
FROM aws.lightsail.key_pairs
WHERE region = '{{ region }}' -- required
;
Returns information about all key pairs in the user's account.
SELECT
name,
arn,
created_at,
fingerprint,
location,
resource_type,
support_code,
tags
FROM aws.lightsail.key_pairs
WHERE region = '{{ region }}' -- required
;
INSERT examples
- create_key_pair
- Manifest
Creates a custom SSH key pair that you can use with an Amazon Lightsail instance. Use the DownloadDefaultKeyPair action to create a Lightsail default key pair in an Amazon Web Services Region where a default key pair does not currently exist. The create key pair operation supports tag-based access control via request tags. For more information, see the Amazon Lightsail Developer Guide.
INSERT INTO aws.lightsail.key_pairs (
keyPairName,
tags,
region
)
SELECT
'{{ keyPairName }}' /* required */,
'{{ tags }}',
'{{ region }}'
RETURNING
key_pair,
operation,
private_key_base_64,
public_key_base_64
;
# Description fields are for documentation purposes
- name: key_pairs
props:
- name: region
value: "{{ region }}"
description: Required parameter for the key_pairs resource.
- name: keyPairName
value: "{{ keyPairName }}"
description: |
The name for your new key pair.
- name: tags
description: |
The tag keys and optional values to add to the resource during create. Use the TagResource action to tag a resource after it's created.
value:
- key: "{{ key }}"
value: "{{ value }}"
DELETE examples
- delete_key_pair
Deletes the specified key pair by removing the public key from Amazon Lightsail. You can delete key pairs that were created using the ImportKeyPair and CreateKeyPair actions, as well as the Lightsail default key pair. A new default key pair will not be created unless you launch an instance without specifying a custom key pair, or you call the DownloadDefaultKeyPair API. The delete key pair operation supports tag-based access control via resource tags applied to the resource identified by key pair name. For more information, see the Amazon Lightsail Developer Guide.
DELETE FROM aws.lightsail.key_pairs
WHERE region = '{{ region }}' --required
;
Lifecycle Methods
- import_key_pair
Imports a public SSH key from a specific key pair.
EXEC aws.lightsail.key_pairs.import_key_pair
@region='{{ region }}' --required
@@json=
'{
"keyPairName": "{{ keyPairName }}",
"publicKeyBase64": "{{ publicKeyBase64 }}"
}'
;