ec2-describe-instance-status Client.InvalidInstanceID.NotFound but I KNOW instance exists

BoomShaka picture BoomShaka · Apr 12, 2013 · Viewed 15.5k times · Source

I have setup a few of the amazon AWS CLI tools (EC2, Auto Scaling, MOnitoring and ELB). The tools are setup correctly and work perfectly. My environment vars are all set, the relevant ones to this Q being:

export EC2_REGION=eu-west-1
export EC2_URL=https://ec2.$EC2_REGION.amazonaws.com
export AWS_ELB_URL=https://elasticloadbalancing.$EC2_REGION.amazonaws.com

When I run ec2-describe-instance-status i-XXXXXXXX for ANY of my instances, I get:

Client.InvalidInstanceID.NotFound: The instance ID 'i-XXXXXXXX' does not exist

I KNOW the instance ID exists, I copied it out of the AWS web console, and it is in the eu-west-1 region, and my env vars are set to this region.

For the life of me I can't figure out why it will not find my instances. Is there anything glaringly obvious that I am doing incorrectly?

UPDATE: recreating x509 cert/pk solved this... for some reason.

Answer

Jujhar Singh picture Jujhar Singh · Sep 23, 2013

I had the same problem. It was because I wasn't defining a region for my commands. I assumed it would list all instances across all regions but it defaults to us-west-1 and I don't have any instances there.

To describe my machines in Ireland I use the following:

ec2-describe-instances --region eu-west-1
NB: I'm defining my AWS access key and secret elsewhere.

To avoid this problem going forward, I've now set my region via an environment variable on my linux and windows machines: EC2_URL=https://ec2.eu-west-1.amazonaws.com so that I don't have to be explicit on the command line.

Update May 2014 You can also set the region by adding the following lines to the ~/.aws/config file in your home folder (not tested on Windows). This is my preferred method now, especially on my VM's and containers:

[default]
region = eu-west-1

For more information see the offical docs here.