Launching EC2 Instance From Command-Line But Can’t Find AMI
April 2, 2013
Posted by on
I was using the command ec2-run-instances to create an EC2 instance. However I kept getting the following error message:
Client.InvalidAMIID.NotFound: The image id '[ami-xxxxxxxx]' does not exist
Error starting (256):
I couldn’t understand it. I was trying to launch the standard Ubuntu Server 64-bit 12.04.1 instance in eu-west-1 (ami-f2191786) but kept getting the above error. I tried other AMI instances and kept getting the above error.
It wasn’t until I explicitly added the region option to the command line that the launch worked. Given that I was specifying a subnet (VPC) that was specific to the eu-west-1 region it puzzles me that this error was being thrown in the first place. Oh well.
To summarise, make sure you add the following flag to your launch:
.. or whatever your region happens to be for that AMI (AMIs are region-specific but ec2-run-instances cannot deduce your region from other region-specific flags such as --subnet).
Note that the --region flag also needs to be specified to many other commands such as ec2-create-tags and ec2-terminate-instances.