Skip to content

Instantly share code, notes, and snippets.

Created June 12, 2015 15:53
Show Gist options
  • Save anonymous/4035d15487d9ca759fd3 to your computer and use it in GitHub Desktop.
Save anonymous/4035d15487d9ca759fd3 to your computer and use it in GitHub Desktop.
[chef=dev] Douglass-MacBook-Pro:~ doug$ cat -n scan.rb
1 #!/usr/bin/ruby
2
3 require 'aws-sdk'
4
5 creds = {
6 'AccessKeyId' => '..',
7 'SecretAccessKey' => '..'
8 }
9 Aws.config[:credentials] = Aws::Credentials.new(creds['AccessKeyId'], creds['SecretAccessKey'])
10 ec2 = Aws::EC2::Resource.new(region:'us-east-1', credentials: creds)
11 filters = [{}]
12 ec2.instances(filters: [{ name: "String", values: ["String"] }]).each {|instance| puts instance }
13
14 #ec2.describe_instances(filters: [{name:'filter-name', values:['filter-value']}])
[chef=dev] Douglass-MacBook-Pro:~ doug$ ./scan.rb
/Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.0/lib/aws-sdk-core/plugins/request_signer.rb:100:in `missing_credentials?': undefined method `set?' for #<Hash:0x007f8219240a48> (NoMethodError)
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.0/lib/aws-sdk-core/plugins/request_signer.rb:92:in `require_credentials'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.0/lib/aws-sdk-core/plugins/request_signer.rb:84:in `sign_authenticated_requests'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.0/lib/aws-sdk-core/plugins/request_signer.rb:77:in `call'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.0/lib/aws-sdk-core/plugins/retry_errors.rb:88:in `call'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.0/lib/aws-sdk-core/query/handler.rb:27:in `call'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.0/lib/aws-sdk-core/plugins/user_agent.rb:12:in `call'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.0/lib/seahorse/client/plugins/endpoint.rb:34:in `call'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.0/lib/aws-sdk-core/plugins/param_validator.rb:21:in `call'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.0/lib/seahorse/client/plugins/raise_response_errors.rb:14:in `call'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.0/lib/aws-sdk-core/plugins/param_converter.rb:21:in `call'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.0/lib/aws-sdk-core/plugins/response_paging.rb:25:in `call'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.0/lib/seahorse/client/plugins/response_target.rb:18:in `call'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.0/lib/seahorse/client/request.rb:70:in `send_request'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.0/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.1.0/lib/aws-sdk-resources/request.rb:24:in `call'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-resources-2.1.0/lib/aws-sdk-resources/operations.rb:127:in `all_batches'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-resources-2.1.0/lib/aws-sdk-resources/collection.rb:18:in `each'
from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-resources-2.1.0/lib/aws-sdk-resources/collection.rb:18:in `each'
from ./scan.rb:12:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment