簡體   English   中英

明明看到實例ID也不存在

[英]The instance ID does not exist even when I clearly see it

我不確定為什么 boto3 找不到我的 EC2 實例。

conn = boto.ec2.connect_to_region('us-east-1')
instance = conn.get_all_instances(["i-0d8d1c65cba1e9066"])[0].instances[0]

給我錯誤:

The instance ID 'i-0d8d1c65cba1e9066' does not exist

在亞馬遜: 在此處輸入圖像描述

我認為您正在使用舊的 boto 庫。 您需要使用 boto3 版本。

py -m pip install boto3 # to install boto3 on your machine

這是片段。

import boto3
ec2_client = boto3.client("ec2", region_name="us-east-1")
response = ec2_client.describe_instances(InstanceIds=["i-0d8d1c65cba1e9066"])
print(response)

希望這可以幫助。 測試后標記為已回答。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM