Discussion:
Setting the aws credentials globally without using the .fog file
JayP
2012-12-14 14:08:39 UTC
Permalink
Hi,

I am using fog in a rails application and I was wondering if there is a way
to set the aws credentials globally instead of using the .fog file. For
example I am using a lot of fog calls in my rails models and would like it
if I can set the aws credentials somewhere in the controller. Is this
possible or I would need to pass it in every time I do something like
"Fog::Compute::AWS.new".

Thanks,
Jay
Kyle Rames
2012-12-14 14:15:33 UTC
Permalink
Hi Jay,

You should be able to pass a hash into the new method containing the
required connection parameters. Here is an example with the Rackspace
Compute service:

connection = Fog::Compute.new({
:provider => 'Rackspace',
:rackspace_username => USERNAME,
:rackspace_api_key => API_KEY
:version => :v2
})
Post by JayP
Hi,
I am using fog in a rails application and I was wondering if there is a
way to set the aws credentials globally instead of using the .fog file.
For example I am using a lot of fog calls in my rails models and would
like it if I can set the aws credentials somewhere in the controller. Is
this possible or I would need to pass it in every time I do something like
"Fog::Compute::AWS.new".
Thanks,
Jay
JayP
2012-12-14 16:49:20 UTC
Permalink
Hi Kyle,

Yeah I'm aware of this approach, I was actually looking for a way to make a
global change kind of like what happens when you run Fog.mock!
Post by Kyle Rames
Hi Jay,
You should be able to pass a hash into the new method containing the
required connection parameters. Here is an example with the Rackspace
connection = Fog::Compute.new({
:provider => 'Rackspace',
:rackspace_username => USERNAME,
:rackspace_api_key => API_KEY
:version => :v2
})
Post by JayP
Hi,
I am using fog in a rails application and I was wondering if there is a
way to set the aws credentials globally instead of using the .fog file.
For example I am using a lot of fog calls in my rails models and would
like it if I can set the aws credentials somewhere in the controller. Is
this possible or I would need to pass it in every time I do something like
"Fog::Compute::AWS.new".
Thanks,
Jay
geemus (Wesley Beary)
2012-12-14 16:52:58 UTC
Permalink
Hey Jay,

Not 100% sure I know what you are after. But you can set
Fog.credentials_path='/path/to/credentials'. Which you could put in say
your rails config directory or something. I think you could then change
that path to something else in order to get something else. Alternatively
you could have keys in your credentials file other than default and do
something like Fog.credential = :non_default_key. Hopefully that helps.

wes
Post by JayP
Hi Kyle,
Yeah I'm aware of this approach, I was actually looking for a way to make
a global change kind of like what happens when you run Fog.mock!
Post by Kyle Rames
Hi Jay,
You should be able to pass a hash into the new method containing the
required connection parameters. Here is an example with the Rackspace
connection = Fog::Compute.new({
:provider => 'Rackspace',
:rackspace_username => USERNAME,
:rackspace_api_key => API_KEY
:version => :v2
})
Post by JayP
Hi,
I am using fog in a rails application and I was wondering if there is a
way to set the aws credentials globally instead of using the .fog file.
For example I am using a lot of fog calls in my rails models and would
like it if I can set the aws credentials somewhere in the controller. Is
this possible or I would need to pass it in every time I do something like
"Fog::Compute::AWS.new".
Thanks,
Jay
Loading...