Class: RenderCFN::DnsWizard

Inherits:
AwsObject show all
Defined in:
lib/renderCFN/dnsWizard.rb

Instance Method Summary collapse

Methods inherited from AwsObject

#get, #name

Constructor Details

#initialize(arguments) ⇒ DnsWizard

Returns a new instance of DnsWizard.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/renderCFN/dnsWizard.rb', line 5

def initialize( arguments )
  @title = arguments[:name]
  @name = "#{@title}DNS"
  @awsObject = { 
    "#{@title}DNS" => {
      'Type' => 'AWS::Route53::RecordSetGroup',
      'Properties' => {
        'HostedZoneId' => arguments[:zoneID],
        'RecordSets' => [ ]
        },
        'DependsOn' => []
      }
    }
end

Instance Method Details

#addARecord(name, ip, ttl = 300) ⇒ Object



20
21
22
# File 'lib/renderCFN/dnsWizard.rb', line 20

def addARecord(name, ip, ttl = 300)
  @awsObject[@name]['Properties']['RecordSets'].push( { 'Name' => name, 'ResourceRecords' => [ ip ], 'Type' => 'A', 'TTL'=> ttl } )
end

#addCNAMERecord(arguments) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/renderCFN/dnsWizard.rb', line 24

def addCNAMERecord( arguments)

  unless arguments[:ttl]
    ttl = 300
  else
    ttl = arguments[:ttl]
  end

  @awsObject[@name]['Properties']['RecordSets'].push( { 'Name' => arguments[:name], 'ResourceRecords' => [ arguments[:target] ], 'Type' => 'CNAME', 'TTL'=> ttl } )
end

#addLbDNS(arguments) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/renderCFN/dnsWizard.rb', line 35

def addLbDNS( arguments)
  @awsObject[@name]['Properties']['RecordSets'].push( 
    { 
      'Name' => "#{arguments[:name]}.#{@@stackType}.#{@@environmentName}.#{@@environmentType}.#{arguments[:zoneTLD]}",
      'Type' => 'A', 
      'AliasTarget'=> {
        'HostedZoneId' => { "Fn::GetAtt" => [ "#{@title}ElasticLoadBalancer", "CanonicalHostedZoneNameID"] },
        'DNSName' => { "Fn::GetAtt" => [ "#{@title}ElasticLoadBalancer", "DNSName"] }
      }
    }
  )
  @awsObject[@name]['DependsOn'].push( "#{@title}ElasticLoadBalancer")
end