Class: VagrantPlugins::CommandDns::Action::Route53::Connect

Inherits:
Object
  • Object
show all
Includes:
Vagrant::Util
Defined in:
lib/vagrant-command-dns/action/route53/connect.rb

Overview

This action connects to AWS, verifies credentials work, and puts the AWS connection object into the ‘:aws_compute` key in the environment.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Connect

Returns a new instance of Connect.



17
18
19
20
# File 'lib/vagrant-command-dns/action/route53/connect.rb', line 17

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new('vagrant_command_dns::action::route53::connect')
end

Instance Method Details

#call(env) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vagrant-command-dns/action/route53/connect.rb', line 22

def call(env)
  # Build the fog config
  fog_config = {
      :provider              => :aws,
      :aws_access_key_id     => env[:machine].config.dns.route53_access_key_id,
      :aws_secret_access_key => env[:machine].config.dns.route53_secret_access_key,
      :aws_session_token     => env[:machine].config.dns.route53_session_token
  }
  fog_config[:version]  = env[:machine].config.dns.route53_version if env[:machine].config.dns.route53_version

  @logger.info('Connecting to AWS...')
  env[:route53] = Fog::DNS.new(fog_config)

  @app.call(env)
end