taylorfinnell / awscr-s3

A Crystal shard for S3.
https://taylorfinnell.github.io/awscr-s3/
MIT License
81 stars 48 forks source link

* Add support for temporary credentials (AWS_SECURITY_TOKEN) #107

Closed philipp-classen closed 5 months ago

philipp-classen commented 2 years ago

I tried to make the naming more consistent, which resulted in a small change in awscr-signer, but I don't have a strong opinion on the naming (-> https://github.com/taylorfinnell/awscr-signer/pull/61).

Now the following code should work if the environment variables are set:

require "awscr-s3"

client = Awscr::S3::Client.new
puts client.list_buckets.buckets

fixes #105

anton7c3 commented 6 months ago

I've tried to do the same, but it turns out that there's a library for obtaining credentials: https://github.com/y2k2mt/aws-credentials.cr The only thing needed here is a session_key added as another argument in the client constructor.

philipp-classen commented 5 months ago

I've tried to do the same, but it turns out that there's a library for obtaining credentials: https://github.com/y2k2mt/aws-credentials.cr The only thing needed here is a session_key added as another argument in the client constructor.

@anton7c3 Thanks, I got it working with your pull requests. For instance, code like this can be used to instantiate a client:

require "aws-credentials"
require "awscr-s3"

include Aws::Credentials

REGION = "us-east-1"
provider = Providers.new([EnvProvider.new, SharedCredentialFileProvider.new] of Provider)
cred = provider.credentials
client = Awscr::S3::Client.new(REGION, cred.access_key_id, cred.secret_access_key, cred.session_token)
philipp-classen commented 5 months ago

Closing this, as it is obsolete now.