簡體   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