Пытаясь получить доступ к aws, используя ruby ​​API, я получаю сообщение об ошибке: http.rb:878: в `initialize': срок выполнения истек (Seahorse::Client::NetworkingError)

При попытке получить доступ к aws через RUBY API на простом примере я получаю сообщение об ошибке:

ruby getAllInstances.rb
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:878:in `initialize': execution expired (Seahorse::Client::NetworkingError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:878:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:878:in `block in connect'

вот скрипт ruby:

#!/usr/bin/env ruby
require 'aws-sdk'
ec2 = Aws::EC2::Resource.new(region: 'us-east-1')

# Get all instances with tag key 'Group'
# and tag value 'MyGroovyGroup':
ec2.instances({filters: [{name: 'tag:op_env', values: ['CI']}]}).each do |i|
  puts 'ID:    ' + i.id
  puts 'State: ' + i.state.name
end

вот среда:

$ больше учетных данных

[default]
aws_access_key_id=####ID####
aws_secret_access_key=######key#####

$ больше конфигурации

[default]
output = json
region = us-east-1

вот еще один скрипт, который я пытаюсь использовать для создания корзины

#!/usr/bin/env ruby
require 'aws-sdk'
#ec2 = Aws::EC2::Resource.new(region: 'us-east-1')
s3 = Aws::S3::Client.new(region: 'us-east-1')
#s3.create_bucket(bucket: 'remove_me')

Aws.use_bundled_cert!
  client = Aws::S3::Client.new(
      :region => 'us-east-1',
      :access_key_id => 'ID',
      :secret_access_key => 'KEY'
  )

  Aws.config[:ssl_verify_peer] = false

  resource = Aws::S3::Resource.new(client:client)

  bucket = resource.bucket('digital-evidance-perftest-data')
  bucket.objects.each do |obj|
      resp = client.get_object(response_target:target, bucket:bucketName, key:obj.key)
   end

с той же ошибкой:

$ ruby ​​create_bucket_s3.rb

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:878:in `initialize': execution expired (Seahorse::Client::NetworkingError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:878:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:878:in `block in connect'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:877:in `connect'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:857:in `start'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/seahorse/client/net_http/connection_pool.rb:285:in `start_session'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/seahorse/client/net_http/connection_pool.rb:92:in `session_for'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/seahorse/client/net_http/handler.rb:119:in `session'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/seahorse/client/net_http/handler.rb:71:in `transmit'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/seahorse/client/net_http/handler.rb:45:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/seahorse/client/plugins/content_length.rb:12:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/s3_request_signer.rb:88:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/s3_request_signer.rb:23:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/xml/error_handler.rb:8:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/helpful_socket_errors.rb:10:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/s3_request_signer.rb:65:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/s3_redirects.rb:15:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/retry_errors.rb:88:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/retry_errors.rb:119:in `retry_request'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/retry_errors.rb:102:in `retry_if_possible'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/retry_errors.rb:90:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/retry_errors.rb:119:in `retry_request'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/retry_errors.rb:102:in `retry_if_possible'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/retry_errors.rb:90:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/retry_errors.rb:119:in `retry_request'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/retry_errors.rb:102:in `retry_if_possible'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/retry_errors.rb:90:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/s3_dualstack.rb:32:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/s3_accelerate.rb:49:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/s3_md5s.rb:31:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/s3_expect_100_continue.rb:21:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/s3_bucket_name_restrictions.rb:12:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/s3_bucket_dns.rb:31:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/rest/handler.rb:7:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/user_agent.rb:12:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/seahorse/client/plugins/endpoint.rb:41:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/s3_url_encoded_keys.rb:40:in `manage_keys'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/s3_url_encoded_keys.rb:32:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/param_validator.rb:21:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/seahorse/client/plugins/raise_response_errors.rb:14:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/s3_sse_cpk.rb:19:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/s3_dualstack.rb:24:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/s3_accelerate.rb:34:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:20:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/idempotency_token.rb:18:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/param_converter.rb:20:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/aws-sdk-core/plugins/response_paging.rb:26:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/seahorse/client/plugins/response_target.rb:21:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/seahorse/client/request.rb:70:in `send_request'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.9.11/lib/seahorse/client/base.rb:207:in `block (2 levels) in define_operation_methods'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-resources-2.9.11/lib/aws-sdk-resources/request.rb:24:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-resources-2.9.11/lib/aws-sdk-resources/operations.rb:139:in `all_batches'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-resources-2.9.11/lib/aws-sdk-resources/collection.rb:18:in `each'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-resources-2.9.11/lib/aws-sdk-resources/collection.rb:18:in `each'
    from create_bucket_s3.rb:19:in `<main>'

1 ответ

Эта ошибка произошла из-за того, что http прокси не экспортировался в среду. После добавления прокси я смог связаться с aws через ruby ​​sdk.

Другие вопросы по тегам