Class: Train::Transports::Aws::Connection
- Inherits:
-
BaseConnection
- Object
- BaseConnection
- Train::Transports::Aws::Connection
- Defined in:
- lib/train/transports/aws.rb
Instance Method Summary collapse
- #aws_client(klass) ⇒ Object
- #aws_resource(klass, args) ⇒ Object
- #connect ⇒ Object
-
#initialize(options) ⇒ Connection
constructor
A new instance of Connection.
- #platform ⇒ Object
- #unique_identifier ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(options) ⇒ Connection
Returns a new instance of Connection.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/train/transports/aws.rb', line 21 def initialize() # Override for any cli options # aws://region/my-profile [:region] = [:host] || [:region] if [:path] # string the leading / from path [:profile] = [:path][1..-1] end super() @cache_enabled[:api_call] = true @cache[:api_call] = {} # additional platform details release = Gem.loaded_specs['aws-sdk'].version @platform_details = { release: "aws-sdk-v#{release}" } connect end |
Instance Method Details
#aws_client(klass) ⇒ Object
45 46 47 48 |
# File 'lib/train/transports/aws.rb', line 45 def aws_client(klass) return klass.new unless cache_enabled?(:api_call) @cache[:api_call][klass.to_s.to_sym] ||= klass.new end |
#aws_resource(klass, args) ⇒ Object
50 51 52 |
# File 'lib/train/transports/aws.rb', line 50 def aws_resource(klass, args) klass.new(args) end |
#connect ⇒ Object
54 55 56 57 |
# File 'lib/train/transports/aws.rb', line 54 def connect ENV['AWS_PROFILE'] = @options[:profile] if @options[:profile] ENV['AWS_REGION'] = @options[:region] if @options[:region] end |
#platform ⇒ Object
41 42 43 |
# File 'lib/train/transports/aws.rb', line 41 def platform force_platform!('aws', @platform_details) end |
#unique_identifier ⇒ Object
63 64 65 66 67 |
# File 'lib/train/transports/aws.rb', line 63 def unique_identifier # use aws account id client = aws_client(::Aws::STS::Client) client.get_caller_identity.account end |
#uri ⇒ Object
59 60 61 |
# File 'lib/train/transports/aws.rb', line 59 def uri "aws://#{@options[:region]}" end |