Skip to content

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

@apurvis

Description

@apurvis
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">

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions