Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws has no compute service #3977

Closed
jgrammen-agilitypr opened this issue Nov 2, 2017 · 8 comments
Closed

aws has no compute service #3977

jgrammen-agilitypr opened this issue Nov 2, 2017 · 8 comments

Comments

@jgrammen-agilitypr
Copy link

Hello,

I am trying to use fog to connect to ec2 and get a list of servers and their instance_id's
fog-aws gem is installed, but an error occurs that I do not understand.

Any help would be much appreciated

code snippet

require 'fog/aws'
ec2 = Fog::Compute.new(
  :provider => 'Aws'
)

error

var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/services_mixin.rb:18:in `rescue in new': aws has no compute service (Fog::Service::NotFound)
        from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/services_mixin.rb:8:in `new'
        from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/compute.rb:54:in `new'
        from /root/autosigner.rb:37:in `<main>'

gem list

bigdecimal (1.2.8)
builder (3.2.3)
CFPropertyList (2.3.5)
did_you_mean (1.0.0)
domain_name (0.5.20170404)
excon (0.59.0)
facter (2.5.1)
fast_gettext (1.1.0)
fission (0.5.0)
fog-aws (1.4.1)
fog-core (1.45.0)
fog-json (1.0.2)
fog-xml (0.1.3)
formatador (0.2.5)
gettext (3.2.4)
gettext-setup (0.28)
hiera (3.4.2)
http-cookie (1.0.3)
inflecto (0.0.2)
io-console (0.4.5)
ipaddress (0.8.3)
json (2.1.0, 1.8.3)
locale (2.1.2)
mime-types (3.1)
mime-types-data (3.2016.0521)
mini_portile2 (2.3.0)
minitest (5.8.4)
multi_json (1.12.2)
net-telnet (0.1.1)
netrc (0.11.0)
nokogiri (1.8.1)
power_assert (0.2.7)
psych (2.0.17)
puppet (5.3.2)
rake (10.5.0)
rbovirt (0.1.4)
rbvmomi (1.11.3)
rdoc (4.2.1)
rest-client (2.0.2)
test-unit (3.1.7)
text (1.3.1)
trollop (2.1.2)
unf (0.1.4)
unf_ext (0.0.7.4)
xml-simple (1.1.5)
@plribeiro3000
Copy link
Member

Hello @jgrammen-agilitypr.

The provider should be AWS instead of Aws

@geemus geemus closed this as completed Nov 2, 2017
@jgrammen-agilitypr
Copy link
Author

Update the code as per the correction

ec2 = Fog::Compute.new(
  :provider => 'AWS'
)

same error

/var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/services_mixin.rb:18:in `rescue in new': aws has no compute service (Fog::Service::NotFound)
        from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/services_mixin.rb:8:in `new'
        from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/compute.rb:54:in `new'
        from /root/autosigner.rb:37:in `<main>'

@geemus geemus reopened this Nov 2, 2017
@jgrammen-agilitypr
Copy link
Author

might be related to, they get similar errors :
fog/fog-aws#248
fog/fog-google#170
mitchellh/vagrant-aws#505

@jgrammen-agilitypr
Copy link
Author

jgrammen-agilitypr commented Nov 2, 2017

attempted to find an older combination of fog-aws and fog-core where the issue would not be present.
Was unsuccessful because old version combinations gave me other errors.

Simplest test case below:

#!/usr/bin/env ruby

require 'fog/aws'

ec2 = Fog::Compute.new(
  :provider => 'AWS'
)
puts ec2

ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]

@jgrammen-agilitypr
Copy link
Author

with old version:

fog-aws (0.9.3)
fog-core (1.38.0)
fog-json (1.0.2)
fog-xml (0.1.3)

the error is still present

/var/lib/gems/2.3.0/gems/fog-core-1.38.0/lib/fog/core/services_mixin.rb:18:in `rescue in new': aws has no compute service (Fog::Service::NotFound)
        from /var/lib/gems/2.3.0/gems/fog-core-1.38.0/lib/fog/core/services_mixin.rb:8:in `new'
        from /var/lib/gems/2.3.0/gems/fog-core-1.38.0/lib/fog/compute.rb:54:in `new'
        from ./test.rb:5:in `<main>'

This is very confusing, that the error would be present in versions that old

0.9.3 - June 20, 2016 (490 KB)
1.38.0 - April 20, 2016 (45.5 KB)

@jgrammen-agilitypr
Copy link
Author

so after much investigation I have narrowed this issue down to the .fog credentials file
so it seems that as soon as it tries to load credentials from the .fog file, something in the service loading breaks???

It does not appear to be related to fog-core or fog-aws versions

root@test:~# ./test.rb
/var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/services_mixin.rb:18:in `rescue in new': aws has no compute service (Fog::Service::NotFound)
        from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/services_mixin.rb:8:in `new'
        from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/compute.rb:54:in `new'
        from ./test.rb:5:in `<main>'
root@test:~# mv .fog .fog.bak
root@test:~# ./test.rb
#<Fog::Compute::AWS::Real:0x00000001b02b00>
root@test:~#

with gem versions:

fog-aws (1.4.1)
fog-core (1.45.0)
fog-json (1.0.2)
fog-xml (0.1.3)

@jgrammen-agilitypr
Copy link
Author

jgrammen-agilitypr commented Nov 2, 2017

finally figured it out.
I had bad yaml in my .fog file

bad config

---
default:
 aws_access_key_id = as
 aws_secret_access_key = ai

good config

---
default:
 aws_access_key_id: as
 aws_secret_access_key: as

the error fog is producing is super un-helpful, as it does not indicate in any way that it failed to parse the .fog yaml file and load credentials.

@geemus
Copy link
Member

geemus commented Nov 2, 2017

Sorry to hear about your difficulty, but I'm glad you found a solution. Thanks for your patience and taking the time to explain your solution, hopefully it can help others (and maybe we can figure out ways to improve the errors as well).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants