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

Cannot instantiate an Aws::S3::Encryption::Client with a passed :region option; only works when ENV['AWS_DEFAULT_REGION'] is set #800

Closed
apurvis opened this issue Apr 30, 2015 · 4 comments

Comments

@apurvis
Copy link

apurvis commented Apr 30, 2015

key = OpenSSL::PKey::RSA.new(1024)
region = 'us-east-1'

s3_client_options = {
  region: region,
  credentials: Aws::Credentials.new(access_key, secret_key),
  encryption_key: key
}

s3_client = Aws::S3::Encryption::Client.new(s3_client_options)
=> Aws::Errors::MissingRegionError: missing region; use :region option or export region name to ENV['AWS_REGION']
    from /data/warehouse/shared/bundle/ruby/2.1.0/gems/aws-sdk-core-2.0.38/lib/aws-sdk-core/plugins/regional_endpoint.rb:30:in `after_initialize'
    from /data/warehouse/shared/bundle/ruby/2.1.0/gems/aws-sdk-core-2.0.38/lib/seahorse/client/base.rb:86:in `block in after_initialize'
    from /data/warehouse/shared/bundle/ruby/2.1.0/gems/aws-sdk-core-2.0.38/lib/seahorse/client/base.rb:85:in `each'
    from /data/warehouse/shared/bundle/ruby/2.1.0/gems/aws-sdk-core-2.0.38/lib/seahorse/client/base.rb:85:in `after_initialize'
    from /data/warehouse/shared/bundle/ruby/2.1.0/gems/aws-sdk-core-2.0.38/lib/seahorse/client/base.rb:23:in `initialize'
    from /data/warehouse/shared/bundle/ruby/2.1.0/gems/aws-sdk-core-2.0.38/lib/aws-sdk-core/client_stubs.rb:19:in `initialize'
    from /data/warehouse/shared/bundle/ruby/2.1.0/gems/aws-sdk-core-2.0.38/lib/seahorse/client/base.rb:107:in `new'
    from /data/warehouse/shared/bundle/ruby/2.1.0/gems/aws-sdk-resources-2.0.38/lib/aws-sdk-resources/services/s3/encryption/client.rb:183:in `initialize'
    from (irb):13:in `new'
    from (irb):13
    from /data/warehouse/shared/bundle/ruby/2.1.0/gems/railties-3.2.19/lib/rails/commands/console.rb:47:in `start'
    from /data/warehouse/shared/bundle/ruby/2.1.0/gems/railties-3.2.19/lib/rails/commands/console.rb:8:in `start'
    from /data/warehouse/shared/bundle/ruby/2.1.0/gems/railties-3.2.19/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

irb(main):016:0* ENV['AWS_DEFAULT_REGION'] = region
=> "us-east-1"

irb(main):017:0> s3_client = Aws::S3::Encryption::Client.new(s3_client_options)
=> #<Aws::S3::Encryption::Client:0x007f331e5f8130 @client=#<Aws::S3::Client>, @key_provider=#<Aws::S3::Encryption::DefaultKeyProvider:0x007f331e5cdfc0 @encryption_materials=#<Aws::S3::Encryption::Materials:0x007f331e5c2058 @key=#<OpenSSL::PKey::RSA:0x007f3321de9c88>, @description="{}">>, @envelope_location=:metadata, @instruction_file_suffix=".instruction">
trevorrowe added a commit that referenced this issue May 1, 2015
The @option tag for the `:client` option contained a typo
preventing it from rendering in the API reference documentation.
The current usage is:

    s3 = Aws::S3::Client.new(region:'...', credentials: ...)
    s3 = Aws::S3::Encryption::Client(client: s3)

See #800
See #801
@trevorrowe
Copy link
Member

Sorry for the confusion. I just pushed a commit that will correct the documentation. You can accomplish what you'd like this way:

s3 = Aws::S3::Client.new(region:'...', credentials: ...)
s3 = Aws::S3::Encryption::Client(client: s3)

@trevorrowe
Copy link
Member

I've added the ability for you to pass client construction options directly to the encryption client. This allows you to now do the following without using the :client option.

s3 = Aws::S3::Encryption::Client(region:'...', credentials: ...)

@trevorrowe
Copy link
Member

Thanks for reporting the issue. I hope this update helps.

@apurvis
Copy link
Author

apurvis commented May 1, 2015

thx; i'll check it out when a release comes out

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