【发布时间】:2017-08-06 00:35:41
【问题描述】:
我正在运行以下脚本:
from __future__ import print_function
import paramiko
import boto3
#print('Loading function')
paramiko.util.log_to_file("/tmp/Dawny.log")
# List of EC2 variables
region = 'us-east-1'
image = 'ami-<>'
keyname = '<>.pem'
ec2 = boto3.resource('ec2')
instances = ec2.create_instances(ImageId=image, MinCount=1, MaxCount=1, InstanceType = 't2.micro', KeyName=keyname)
instance = instances[0]
instance.wait_until_running()
instance.load()
print(instance.public_dns_name)
def lambda_handler(event, context):
instances = ec2.create_instances(ImageId=image, MinCount=1, MaxCount=1, InstanceType = 't2.micro', KeyName=keyname)
instance = instances[0]
instance.wait_until_running()
instance.load()
print(instance.public_dns_name)
当我运行它时,我得到了这个错误
botocore.exceptions.ClientError: An error occurred (InvalidKeyPair.NotFound) when calling the RunInstances operation: The key pair '<>.pem' does not exist
即使我将完整路径添加到密钥对,boto3 也会给我同样的错误。 另外,我也试过这个:https://stackoverflow.com/a/34410564/4993513
还是不行。
【问题讨论】:
标签: python amazon-web-services amazon-ec2 boto3