I did this:
try:
ec2.get_all_key_pairs(keynames=[key_name])[0]
print 'Key pair %s exist'%key_name
except ec2.ResponseError, e:
if e.code == 'InvalidKeyPair.NotFound':
print 'Creating key_pair %s'%key_name
key = ec2.create_key_pair(key_name)
else:
raise
And as you can see, I created a key_pair, but forgot to save it =( Than I launched instance and realized that I don't have .pem file on my computer, is there any way to recreate it?