I'm using AWS-SDK gem in my Rails project, and I want a kind-of initializer file to connect directly to my repo and make changes directly in the Rails console, something like this:
# At config/initializers/aws.rb
Aws::S3::Client.new(
:access_key_id => 'ACCESS_KEY_ID',
:secret_access_key => 'SECRET_ACCESS_KEY'
)
I've looked for documentation or tutorials but it's not clear for me. How do I do it? Thank you!
A Ruby on Rails plugin that integrates AWS services with your application using the latest version of AWS SDK For Ruby. If you want to use other services (such as S3), you will still need to add them to your Gemfile: You will have to ensure that you provide credentials for the SDK to use. See the latest AWS SDK for Ruby Docs for details.
You can see a full list of supported gems in the README on our GitHub page, which also includes a detailed upgrading guide for version 2 users. Other gems relevant to Ruby developers include: aws-sdk-rails: Provides Ruby on Rails integrations for the AWS SDK for Ruby.
To use the SDK, you must set either AWS credentials or create an AWS STS access token, and set the AWS Region you want to use. Access keys consist of an access key ID and secret access key, which are used to sign programmatic requests that you make to AWS. If you don’t have access keys, you can create them by using the Management Console.
Ruby on Rails Active Storage out of the box comes equipped with four different file storage options: 1 a local disk-based service, useful for development and testing, 2 Google Cloud Platform, 3 Amazon AWS S3, 4 Microsoft Azure Storage,
i think you can try like this
put this in aws.rb
AWS.config(
:access_key_id => ENV['ACCESS_KEY_ID'],
:secret_access_key => ENV['SECRET_ACCESS_KEY']
)
and when you initialize the object wherever you need, will call the configuration
s3 = AWS::S3.new
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With