Skip to main content

key_pairs

Creates, updates, deletes, gets or lists a key_pairs resource.

Overview

Namekey_pairs
TypeResource
Idaws.lightsail.key_pairs

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringThe friendly name of the SSH key pair. (pattern: <code>\w[\w-]*\w</code>)
arnstringThe 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_atstring (date-time)The timestamp when the key pair was created (1479816991.349).
fingerprintstringThe RSA fingerprint of the key pair.
locationobjectThe region name and Availability Zone where the key pair was created.
resource_typestringThe 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_codestringThe 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.
tagsarrayThe 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:

NameAccessible byRequired ParamsOptional ParamsDescription
get_key_pairselectregionReturns information about a specific key pair.
get_key_pairsselectregionReturns information about all key pairs in the user's account.
create_key_pairinsertregion, keyPairNameCreates 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_pairdeleteregionDeletes 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_pairexecregion, keyPairName, publicKeyBase64Imports 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.

NameDatatypeDescription
regionstringAWS region (default: us-east-1)

SELECT examples

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
;

INSERT examples

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
;

DELETE examples

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

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 }}"
}'
;