The AMI ID 'ami-a0215ff2' does not exist when in ap-southeast zone

745 views
Skip to first unread message

Matt

unread,
Oct 8, 2010, 9:41:27 PM10/8/10
to Maestro Users
Hi Brian,

I have an issue when running rake start task on my cloud.

I have configured my node as follow:

ec2_node "webserver-1" do
roles ["webserver"]
ami "ami-a0215ff2"
ssh_user "ubuntu"
instance_type "m1.small"
availability_zone "ap-southeast-1a"
end

And it says "The AMI ID 'ami-a0215ff2' does not exist". That AMI does
exist in the Singapore zone. I know maestro calls ec2.run_instances
from amazon-ec2 gem but i don't understand why it can't find that AMI.

I tried with ami in us-east zone and that works. I wonder if it's
limited to us-east zones. Do you know?

Thank you!
Matt

Brian Ploetz

unread,
Oct 9, 2010, 2:50:16 AM10/9/10
to Maestro Users
Hey Matt,

Keypairs are associated with specific regions. Is the keypair you're
using in your cloud file associated with the Asia Pacific region? That
fact that you were able to launch an AMI in a us-east availability
zone seems to suggest that you're using a us-east keypair.

Try creating a keypair in the Asia Pacific region and use it in your
cloud file with this AMI. Does it work then?
BP

Matt

unread,
Oct 9, 2010, 4:17:56 AM10/9/10
to Maestro Users
No it's the same, i know keypair are specific to each region. I'd my
own keypair in AP zone.
Wasn't working.
So i created a new keypair in US-east, changed the path to the keypair
and it worked.
Not sure what the problem is.

Thanks / Matt

Brian Ploetz

unread,
Oct 9, 2010, 2:56:33 PM10/9/10
to Maestro Users
OK, I think I see what's going on.

The AWS::Base constructor takes a :server argument which lets you
define which Amazon Web Services endpoint you want to use (i.e. which
region to operate in)

http://rdoc.info/github/grempe/amazon-ec2/master/AWS/Base#initialize-instance_method

If you do not specify a :server, it defaults to an endpoint in US-
East, or the endpoint specified by the EC2_URL environment variable if
present:


module AWS
module EC2

# Which host FQDN will we connect to for all API calls to AWS?
# If EC2_URL is defined in the users ENV we can override the
default with that.
#
# @example
# export EC2_URL='https://ec2.amazonaws.com'
if ENV['EC2_URL']
EC2_URL = ENV['EC2_URL']
DEFAULT_HOST = URI.parse(EC2_URL).host
else
# Default US API endpoint
DEFAULT_HOST = 'ec2.amazonaws.com'
end

API_VERSION = '2009-11-30'

class Base < AWS::Base
def api_version
API_VERSION
end

def default_host
DEFAULT_HOST
end
end

end
end


There are different environment variables for S3, RDS, etc......

When Maestro constructs an AWS::EC2::Base instance, it's not passing
anything in for the :server, and thus you get the default (see the
connect! method here: http://github.com/bploetz/maestro/blob/master/lib/maestro/cloud/aws.rb).

I created an issue on GitHub to allow users to explicitly specify the
region they want to use in their cloud file, so they don't have to
deal with setting environment variables:

http://github.com/bploetz/maestro/issues#issue/15

In the mean time, you can set the EC2_URL environment variable to
switch to Asia Pacific. I tried this out in irb and it works:

# Default
[bploetz:~/Desktop]> irb
ruby-1.9.2-p0 > require 'rubygems'
=> true
ruby-1.9.2-p0 > require 'AWS'
=> true
ruby-1.9.2-p0 > ACCESS_KEY_ID = "XXXXXXXXXXXXXXXXXXXXXX"
=> "XXXXXXXXXXXXXXXXXXXX"
ruby-1.9.2-p0 > SECRET_ACCESS_KEY =
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
=> "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
ruby-1.9.2-p0 > ec2 = AWS::EC2::Base.new(:access_key_id =>
ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY)
=> #<AWS::EC2::Base:0x00000100a4cf80 @server="ec2.us-
east-1.amazonaws.com", @proxy_server=nil, @use_ssl=true, @port=443,
@access_key_id="XXXXXXXXXXXXXXXXXXXXXXX",
@secret_access_key="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
@http=#<Net::HTTP ec2.us-east-1.amazonaws.com:443 open=false>>
ruby-1.9.2-p0 > ec2.run_instances(:image_id => 'ami-
a0215ff2', :key_name => 'asia', :availability_zone => 'ap-
southeast-1a')
AWS::InvalidAMIIDNotFound: The AMI ID 'ami-a0215ff2' does not exist
from /Users/bploetz/.rvm/gems/ruby-1.9.2-p0@test-asia/gems/amazon-
ec2-0.9.15/lib/AWS.rb:319:in `aws_error?'
from /Users/bploetz/.rvm/gems/ruby-1.9.2-p0@test-asia/gems/amazon-
ec2-0.9.15/lib/AWS.rb:259:in `block in make_request'
from /Users/bploetz/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/
http.rb:627:in `start'
from /Users/bploetz/.rvm/gems/ruby-1.9.2-p0@test-asia/gems/amazon-
ec2-0.9.15/lib/AWS.rb:233:in `make_request'
from /Users/bploetz/.rvm/gems/ruby-1.9.2-p0@test-asia/gems/amazon-
ec2-0.9.15/lib/AWS.rb:283:in `response_generator'
from /Users/bploetz/.rvm/gems/ruby-1.9.2-p0@test-asia/gems/amazon-
ec2-0.9.15/lib/AWS/EC2/instances.rb:72:in `run_instances'
from (irb):6
from /Users/bploetz/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'
ruby-1.9.2-p0 > exit


# Set it to Asia Pacific
[bploetz:~/Desktop]> export EC2_URL="https://ec2.ap-
southeast-1.amazonaws.com"
[bploetz:~/Desktop]> irb
ruby-1.9.2-p0 > require 'rubygems'
=> true
ruby-1.9.2-p0 > require 'AWS'
=> true
ruby-1.9.2-p0 > ACCESS_KEY_ID = "XXXXXXXXXXXXXXXXXXXXXXXXX"
=> "XXXXXXXXXXXXXXXXXXXXX"
ruby-1.9.2-p0 > SECRET_ACCESS_KEY =
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
=> "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
ruby-1.9.2-p0 > ec2 = AWS::EC2::Base.new(:access_key_id =>
ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY)
=> #<AWS::EC2::Base:0x00000100a30060 @server="ec2.ap-
southeast-1.amazonaws.com", @proxy_server=nil, @use_ssl=true,
@port=443, @access_key_id="XXXXXXXXXXXXXXXXXXXXX",
@secret_access_key="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @http=#<Net::HTTP
ec2.ap-southeast-1.amazonaws.com:443 open=false>>
ruby-1.9.2-p0 >
ruby-1.9.2-p0 > ec2.run_instances(:image_id => 'ami-
a0215ff2', :key_name => 'asia', :availability_zone => 'ap-
southeast-1a')
=> {"xmlns"=>"http://ec2.amazonaws.com/doc/2009-11-30/",
"requestId"=>"0200e09c-34e3-45d6-9a5e-f67f6c7d1c81",
"reservationId"=>"r-7a6a5228", "ownerId"=>"105150334863",
"groupSet"=>{"item"=>[{"groupId"=>"default"}]},
"instancesSet"=>{"item"=>[{"instanceId"=>"i-aa0338f8", "imageId"=>"ami-
a0215ff2", "instanceState"=>{"code"=>"0", "name"=>"pending"},
"privateDnsName"=>nil, "dnsName"=>nil, "reason"=>nil,
"keyName"=>"asia", "amiLaunchIndex"=>"0", "productCodes"=>nil,
"instanceType"=>"m1.small", "launchTime"=>"2010-10-09T18:14:56.000Z",
"placement"=>{"availabilityZone"=>"ap-southeast-1a"},
"kernelId"=>"aki-38354b6a", "monitoring"=>{"state"=>"disabled"},
"stateReason"=>{"code"=>"pending", "message"=>"pending"},
"rootDeviceType"=>"instance-store", "blockDeviceMapping"=>nil}]}}
ruby-1.9.2-p0 > exit

Matt

unread,
Oct 9, 2010, 8:59:29 PM10/9/10
to Maestro Users
Well spotted. I did not see that, i did you to Amazon API (and gem) to
look at RunInstances but not #new.

For some reason the EC2_URL would not work for me.
It would say:
> rake maestro:production:start
rake aborted!
Invalid EC2_URL environment variable : https://ec2.ap-southeast-1.amazonaws.com

So i went in maestro and updated the EC2, ELB and RDS to pass in the
region for cloud configuration.
And that worked!

I did this in AWS.rb
def connect!
@ec2 = AWS::EC2::Base.new(:access_key_id =>
aws_access_key, :secret_access_key => aws_secret_access_key, :use_ssl
=> true, :server => "ec2.#{region}.amazonaws.com")
@elb = AWS::ELB::Base.new(:access_key_id =>
aws_access_key, :secret_access_key => aws_secret_access_key, :use_ssl
=> true, :server => "elasticloadbalancing.#{region}.amazonaws.com")
@rds = AWS::RDS::Base.new(:access_key_id =>
aws_access_key, :secret_access_key => aws_secret_access_key, :use_ssl
=> true, :server => "rds.#{region}.amazonaws.com")
s3_logger = Logger.new(STDOUT)
s3_logger.level = Logger::FATAL
AWS::S3::Base.establish_connection!(:access_key_id =>
aws_access_key, :secret_access_key => aws_secret_access_key, :use_ssl
=> true)
end

with the cloud config having in the general cloud configuration like
you suggested.
region "ap-southeast-1"

That's a good start.

Thanks / Matt

On Oct 10, 5:56 am, Brian Ploetz <bplo...@gmail.com> wrote:
> OK, I think I see what's going on.
>
> The AWS::Base constructor takes a :server argument which lets you
> define which Amazon Web Services endpoint you want to use (i.e. which
> region to operate in)
>
> http://rdoc.info/github/grempe/amazon-ec2/master/AWS/Base#initialize-...

Brian Ploetz

unread,
Oct 10, 2010, 11:21:27 PM10/10/10
to Maestro Users
Hi Matt,

This issue has been fixed in Maestro 0.4.1. Please see the updated
Readme on GitHub for details on how to set the region, and then take
0.4.1 out for a spin.

Let me know if you run into any issues. Thanks.
BP

Matt

unread,
Oct 11, 2010, 12:52:56 AM10/11/10
to Maestro Users
Yep, saw that. Very good!

Thank you
Reply all
Reply to author
Forward
0 new messages