jeudi 27 août 2015

Getting private key from ServiceResource create_key_pair

I know how to obtain the private key of a AWS Key Pair in boto3:

import boto3
client = boto3.client('ec2')
dict_key_pair = client.create_key_pair(KeyName="temp-1")
private_key = dict_key_pair['KeyMaterial']

But I'd prefer to get a EC2.KeyPair instance instead of a dict.

I understand that the way to create such an instance is:

service_resource = boto3.resource('ec2')
entity_key_pair = service_resource.create_key_pair(KeyName="temp-2")

Unfortunately I cannot find out how to extract the private key from the newly created object.




Aucun commentaire:

Enregistrer un commentaire