Module: S3
Instance Method Summary collapse
-
#read(bucket, key) ⇒ Object
Read value from key in S3 bucket, with logging.
-
#s3 ⇒ Object
Get the underlying AWS::S3::Client instance, creating it using environment vars if necessary.
-
#write(bucket, key, value) ⇒ Object
Write value to key in S3 bucket, with logging.
Instance Method Details
#read(bucket, key) ⇒ Object
Read value from key in S3 bucket, with logging.
21 22 23 24 25 |
# File 'lib/vault-tools/s3.rb', line 21 def read(bucket, key) Vault::Log.log(:fn => __method__, :key => key) do s3.get_object({bucket: bucket, key: key}).body.read end end |
#s3 ⇒ Object
Get the underlying AWS::S3::Client instance, creating it using environment vars if necessary.
29 30 31 32 33 34 35 |
# File 'lib/vault-tools/s3.rb', line 29 def s3 @s3 ||= Aws::S3::Client.new( credentials: Aws::Credentials.new(Config.env('AWS_ACCESS_KEY_ID'), Config.env('AWS_SECRET_ACCESS_KEY')), region: Config.env('AWS_REGION') ) end |