Class: Train::Transports::Aws::Connection

Inherits:
BaseConnection
  • Object
show all
Defined in:
lib/train/transports/aws.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Connection



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/train/transports/aws.rb', line 21

def initialize(options)
  # Override for any cli options
  # aws://region/my-profile
  options[:region] = options[:host] || options[:region]
  if options[:path]
    # string the leading / from path
    options[:profile] = options[:path][1..-1]
  end
  super(options)

  @cache_enabled[:api_call] = true
  @cache[:api_call] = {}

  connect
end

Instance Method Details

#aws_client(klass) ⇒ Object



41
42
43
44
# File 'lib/train/transports/aws.rb', line 41

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



46
47
48
# File 'lib/train/transports/aws.rb', line 46

def aws_resource(klass, args)
  klass.new(args)
end

#connectObject



50
51
52
53
# File 'lib/train/transports/aws.rb', line 50

def connect
  ENV['AWS_PROFILE'] = @options[:profile] if @options[:profile]
  ENV['AWS_REGION'] = @options[:region] if @options[:region]
end

#platformObject



37
38
39
# File 'lib/train/transports/aws.rb', line 37

def platform
  direct_platform('aws')
end

#uriObject



55
56
57
# File 'lib/train/transports/aws.rb', line 55

def uri
  "aws://#{@options[:region]}"
end