Class: MinimalPipeline::Crossing
- Inherits:
-
Object
- Object
- MinimalPipeline::Crossing
- Defined in:
- lib/minimal_pipeline/crossing.rb
Overview
Here is an example of how to use this class to interact with Crossing.
“‘ crossing = MinimalPipeline::Crossing.new
# Upload crossing.upload_content(‘my-config-bucket’, ‘example.txt’, ‘foo’)
# Download content = crossing.download_file(‘my-config-bucket’, ‘example.txt’) puts content # Outputs ‘foo’ “‘
You will need the following environment variables to be present:
-
‘AWS_REGION` or `region`
-
‘keystore_kms_id`
For more information on Crossing see github.com/stelligent/crossing
Instance Method Summary collapse
-
#download_file(config_bucket, filename) ⇒ String
Securely downloads a file from an S3 bucket.
-
#initialize ⇒ Crossing
constructor
A new instance of Crossing.
-
#upload_content(config_bucket, filename, content) ⇒ Object
Securely uploads a file to an S3 bucket.
Constructor Details
#initialize ⇒ Crossing
Returns a new instance of Crossing.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/minimal_pipeline/crossing.rb', line 26 def initialize raise 'You must set env variable AWS_REGION.' if ENV['AWS_REGION'].nil? raise '`keystore_kms_id` in environment!' \ if ENV['keystore_kms_id'].nil? region = ENV['AWS_REGION'] kms = Aws::KMS::Client.new(region: region) s3 = Aws::S3::Encryption::Client.new(kms_key_id: ENV['keystore_kms_id'], kms_client: kms, region: region) @crossing = ::Crossing.new(s3) end |
Instance Method Details
#download_file(config_bucket, filename) ⇒ String
Securely downloads a file from an S3 bucket
55 56 57 |
# File 'lib/minimal_pipeline/crossing.rb', line 55 def download_file(config_bucket, filename) @crossing.get_content(config_bucket, filename) end |
#upload_content(config_bucket, filename, content) ⇒ Object
Securely uploads a file to an S3 bucket
45 46 47 |
# File 'lib/minimal_pipeline/crossing.rb', line 45 def upload_content(config_bucket, filename, content) @crossing.put_content(config_bucket, filename, content) end |