ec2.describe_instances returns an empty Reservations list

0

I have an ec2 instance running.
If I use the aws cli command "aws ec2 describe-instances" I get this instance.
However when I try boto3 code:

import boto3
    
ec2 = boto3.client('ec2')
response = ec2.describe_instances()
print(response)

I get an empty Reservations list.

Any idea?

Edited by: amirdolev on Apr 20, 2020 1:34 AM

已提問 4 年前檢視次數 1197 次
1 個回答
0

Problem was that I had a default region defined in the ~/.aws/config file. Since my running instance was in a different region, it was not identified.

已回答 4 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南