繁体   English   中英

未授权图像:boto3 错误

[英]Not authorized for images: boto3 error

我正在尝试运行此脚本:

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)

我在完成所有 aws 配置的服务器上运行此脚本(在aws configure

而且,当我运行它时,出现此错误:

botocore.exceptions.ClientError: 调用 RunInstances 操作时发生错误 (AuthFailure):未授权图像:[ami-<>]

有什么理由吗? 而且,我该如何解决?

[图像是私人的。 但是,由于我在服务器上配置了 boto,从技术上讲,这应该不是问题,对吧?]

这个错误的答案很少

  1. 参数不足,但 create_instance 给出了另一个错误。 例如,缺少 VPC-id、子网 ID、安全组。

  2. 凭证中的 API 访问密钥无权启动运行实例。 请转到 IAM 并检查您的用户是否获得了足够的角色来执行任务。

如果您尝试在 AWS Console > EC2 > Key Pairs 中使用密钥对文件名而不是实际名称,则可能会遇到此错误

aws ec2 run-instances --image-id ami-123457916 --instance-type t3.nano 
--key-name **my_ec2_keypair.pem**

应该是 KeyPair 的名称,而不是 KeyPair 的文件名。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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