简体   繁体   中英

AWS SDK for Python - Boto - KeyPair Creation Confusion

I am trying to create a EC2 key-pair using the create_key_pair() method, something like:

key_name = 'BlockChainEC2InstanceKeyPair-1'    
def create_new_key_pair(key_name):
    newKey = objEC2.create_key_pair(key_name)
    newKey.save(dir_to_save_new_key)

The keys are created as I can fetch these using the get_all_key_pairs() method like below:

def get_all_keypairs():
    try:
         key= objEC2.get_all_key_pairs()
    except:
        raise

get_all_key_pairs() returns the result like below showing that the keypair exists:

<DescribeKeyPairsResponse xmlns="http://ec2.amazonaws.com/doc/2014-10-01/">
    <requestId>8d3faa7d-70c2-4b7c-ad18-810f23230c22</requestId>
    <keySet>
        <item>
            <keyName>BlockChainEC2InstanceKeyPair-1</keyName>
            <keyFingerprint>30:51:d4:19:a5:ba:11:dc:7e:9d:ca:49:10:01:30:34:b5:7e:9b:8a</keyFingerprint>
        </item>
        <item>
            <keyName>BlockChainEC2InstanceKeyPair-1.pem</keyName>
            <keyFingerprint>18:7e:ba:2c:44:67:44:a7:06:c4:68:3a:47:00:88:8f:31:98:27:e6</keyFingerprint>
        </item>
    </keySet>
</DescribeKeyPairsResponse>

My problem is when I log into my AWS console for the same account whose access keys I used to create the keypairs - I don't get to find the keys.

Question is : Where in my AWS console can I see the key-pair I created using the create_key_pair() method.

The keypairs are for each region. I suspect you are creating the keypair in one region using boto and you are checking for the keypair in a different region in your AWS console.

Make sure you default region in boto ( .aws/config ) and check your AWS dashboard is in the same region. If not change the region in the dashboard to match your boto default region and your keypair will appear there.

Or pass the region parameter when creating the EC2 object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM