Module: Formatron::CloudFormation::Resources::Route53

Defined in:
lib/formatron/cloud_formation/resources/route53.rb

Overview

Generates CloudFormation template Route53 resources

Class Method Summary collapse

Class Method Details

.hosted_zone(name:, vpc:) ⇒ Object

rubocop:disable Metrics/MethodLength



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/formatron/cloud_formation/resources/route53.rb', line 9

def self.hosted_zone(name:, vpc:)
  {
    Type: 'AWS::Route53::HostedZone',
    Properties: {
      HostedZoneConfig: {
        Comment: Template.join(
          'Private Hosted Zone for CloudFormation Stack: ',
          Template.ref('AWS::StackName')
        )
      },
      Name: name,
      VPCs: [{
        VPCId: Template.ref(vpc),
        VPCRegion: Template.ref('AWS::Region')
      }]
    }
  }
end

.record_set(hosted_zone_id:, sub_domain:, hosted_zone_name:, instance:, attribute:) ⇒ Object

rubocop:disable Metrics/MethodLength



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/formatron/cloud_formation/resources/route53.rb', line 30

def self.record_set(
  hosted_zone_id:,
  sub_domain:,
  hosted_zone_name:,
  instance:,
  attribute:
)
  {
    Type: 'AWS::Route53::RecordSet',
    Properties: {
      HostedZoneId: hosted_zone_id,
      Name: "#{sub_domain}.#{hosted_zone_name}",
      ResourceRecords: [
        Template.get_attribute(instance, attribute)
      ],
      TTL: '900',
      Type: 'A'
    }
  }
end