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::AssumeRoleCredentials throwing exception about :region #957

Closed
zepplen opened this issue Oct 13, 2015 · 1 comment
Closed

Aws::AssumeRoleCredentials throwing exception about :region #957

zepplen opened this issue Oct 13, 2015 · 1 comment
Labels
guidance Question that needs advice or information.

Comments

@zepplen
Copy link

zepplen commented Oct 13, 2015

I am having an issue using the Aws::AssumeRoleCredentials call. It is throwing an exception requiring :region to be set. Setting :region does not fix the issues.

ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
[1] pry(main)> require 'aws-sdk'
�[0G[2] pry(main)> Aws::VERSION
[3] pry(main)> assumed_credentials = Aws::AssumeRoleCredentials.new(
[3] pry(main)*       role_arn: 'arn:aws:iam::111111111111:role/role_name',
[3] pry(main)*       role_session_name: 'example_session'
[3] pry(main)*   )
[4] pry(main)> puts
[5] pry(main)> puts
[6] pry(main)> puts 'Trying to set :region'
[7] pry(main)> assumed_credentials = Aws::AssumeRoleCredentials.new(
[7] pry(main)*       region: 'us-east-1',
[7] pry(main)*       role_arn: 'arn:aws:iam::111111111111:role/role_name',
[7] pry(main)*       role_session_name: 'example_session'
[7] pry(main)*   )
[8] pry(main)> puts
[9] pry(main)> puts
[10] pry(main)> puts 'Work around'
[11] pry(main)> Aws.config[:region] = 'us-east-1'
[12] pry(main)> assumed_credentials = Aws::AssumeRoleCredentials.new(
[12] pry(main)*       role_arn: 'arn:aws:iam::111111111111:role/role_name',
[12] pry(main)*       role_session_name: 'example_session'
[12] pry(main)*   )
[13] pry(main)> Aws.config.delete(:region)
[14] pry(main)> puts
[15] pry(main)> puts
[16] pry(main)> puts 'Workaound w/ region set'
[17] pry(main)> Aws.config[:region] = 'us-east-1'
[18] pry(main)> assumed_credentials = Aws::AssumeRoleCredentials.new(
[18] pry(main)*       region: 'us-east-1',
[18] pry(main)*       role_arn: 'arn:aws:iam::111111111111:role/role_name',
[18] pry(main)*       role_session_name: 'example_session'
[18] pry(main)*   )
[19] pry(main)> Aws.config.delete(:region)
[20] pry(main)> exit
=> true
=> "2.1.29"
Aws::Errors::MissingRegionError: missing region; use :region option or export region name to ENV['AWS_REGION']
from /home/mtrimmer/.rvm/gems/ruby-2.1.5@wormhole/gems/aws-sdk-core-2.1.29/lib/aws-sdk-core/plugins/regional_endpoint.rb:32:in `after_initialize'

=> nil

=> nil
Trying to set :region
=> nil
Aws::Errors::MissingRegionError: missing region; use :region option or export region name to ENV['AWS_REGION']
from /home/mtrimmer/.rvm/gems/ruby-2.1.5@wormhole/gems/aws-sdk-core-2.1.29/lib/aws-sdk-core/plugins/regional_endpoint.rb:32:in `after_initialize'

=> nil

=> nil
Work around
=> nil
=> "us-east-1"
=> #<Aws::AssumeRoleCredentials:0x00000001526380
 @client=#<Aws::STS::Client>,
 @credentials=#<Aws::Credentials access_key_id="********************">,
 @expiration=2015-10-13 19:53:11 UTC,
 @mutex=#<Mutex:0x00000000f000f0>,
 @options=
  {:role_arn=>"arn:aws:iam::111111111111:role/role_name",
   :role_session_name=>"example_session"}>
=> "us-east-1"

=> nil

=> nil
Workaound w/ region set
=> nil
=> "us-east-1"
ArgumentError: unexpected value at params[:region]
from /home/mtrimmer/.rvm/gems/ruby-2.1.5@wormhole/gems/aws-sdk-core-2.1.29/lib/aws-sdk-core/param_validator.rb:26:in `validate!'
=> "us-east-1"
trevorrowe added a commit that referenced this issue Oct 13, 2015
@trevorrowe
Copy link
Member

The stack trace isn't very helpful unless you look pretty deep. When you construct an instance of Aws::AssumeRoleCredentials, an Aws::STS::Client is constructed when one is not given. This client requires a region. The client class will attempt to load the region from ENV['AWS_REGION'] but it seems like a pass-through like you attempted would be more helpful.

I've fixed the documentation so that the :client option will appear in the api docs. I'll see about making the region option (and others) pass through to the client constructor call.

awood45 added a commit that referenced this issue Oct 15, 2015
@srchase srchase added the guidance Question that needs advice or information. label Dec 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

3 participants