How can I load aws credentials to ruby if I use bundler console.
Scenario:
I have the following code in samplefile.rb and aws credentials in ~/.aws/credentials
require 'aws-sdk-core'
require 'aws-sdk-s3'
require 'json'
class Publisher
def listBuckets
profile_name = 'AWSConsumer'
region = "us-east-1"
s3 = Aws::S3::Client.new(profile: profile_name, region:region)
resp = s3.list_buckets
resp.buckets.each do |bucket|
puts bucket.name
end
end
Publisher.new.listBuckets
This is working fine by taking the shared credentials when I use $ruby samplefile.rb
but when I execute the same using $bundle exec bin/console
Getting missing credentials .
missing credentials, provide credentials with one of the following options: - :access_key_id and :secret_access_key - :credentials - :credentials_provider
As per the AWS documentation, its should load the shared credentials for ruby.