2016-03-21 8 views
0

Boto3(リソースレベル)KeyPairKeypairInfoオブジェクトの目的は何ですか?ドキュメントがまだ再び曖昧..ですBoto3:(EC2)KeyPairとKeyPairInfoの違い

import boto3 
ec2 = boto3.resource('ec2') 
key_pair = ec2.KeyPair('name') 
key_pair = ec2.KeyPairInfo('name') 

重要なのは、KeyPairInfoは全く動作しません:AttributeError: 'ec2.ServiceResource' object has no attribute 'KeyPairInfo'

さらに:どちらも、新しい鍵ペアを作成することはできません

  • 、なぜ私たちはすべてでそれらを持っているのですか?
  • print key_pair_info.key_material
    AttributeError: 'ec2.KeyPairInfo' object has no attribute 'key_material'。これは、作成中にkey_materialが一度ユーザーに与えられたためです。
  • だけの情報のため、私は主に秘密鍵を返さないbotocore(client)

    答えて

    1
    ec2 = boto3.resource('ec2') 
    ec2.KeyPair('name') # Get the key fingerprint AND the private key 
    ec2.KeyPairInfo('name') # Get the key fingerprint ONLY 
    
    
    ec2 = boto3.client('ec2') 
    mykeypair = ec2.create_key_pair(KeyName='name') # Create a new keypair 
    print mykeypair['KeyMaterial'] 
    
    +0

    '応答= ec2.KeyPair( '名前')'で動作します。指紋と名前だけが返されます。ドキュメントには 'response.key_material'が返されると書かれていますが、awsは私有鍵を格納していないのでfalseです[http://boto3.readthedocs.org/en/latest/reference/services/ec2.html#keypair] – bluemoon

    関連する問題