15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/vagrant-aws-dns-synchronous/action/base.rb', line 15
def call(env)
return @app.call(env) if @machine.config.dns.record_sets.nil?
@aws = AwsDns::Util::AwsUtil.new(@machine.provider_config.access_key_id,
@machine.provider_config.secret_access_key,
@machine.provider_config.region)
instance = @aws.instance_info(@machine.id)
@machine.config.dns.record_sets.each do |record_set|
hosted_zone_id, record, type, value = record_set
zone_type = @aws.get_zone_type(hosted_zone_id)
default_value = if type == 'CNAME'
instance.public_send("#{zone_type}_dns_name")
else
instance.public_send("#{zone_type}_ip_address")
end
yield hosted_zone_id, record, type, value || default_value if block_given?
end
@app.call(env)
end
|