Sha256: f4930c6354e0047fde65e95166d310f609c0562b756ec11e8ff272bfdec061c7

Contents?: true

Size: 1.67 KB

Versions: 130

Compression:

Stored size: 1.67 KB

Contents

# CloudFormation Docs AWS::Route53::RecordSet: https://amzn.to/2BtP9s5
#
# Example:
#
#   DnsRecord:
#     Type: AWS::Route53::RecordSet
#     Properties:
#       HostedZoneName: !Ref 'HostedZoneResource'
#       Comment: DNS name for my instance.
#       Name: !Join ['', [!Ref 'Ec2Instance', ., !Ref 'AWS::Region', ., !Ref 'HostedZone', .]]
#       Type: A
#       TTL: '900'
#       ResourceRecords:
#       - !GetAtt Ec2Instance.PublicIp
module Jets::Resource::Route53
  class RecordSet < Jets::Resource::Base
    def definition
      {
        dns_record: {
          type: "AWS::Route53::RecordSet",
          properties: {
            hosted_zone_name: hosted_zone_name,
            comment: "DNS record managed by Jets",
            name: name,
            type: "CNAME",
            ttl: "60",
            resource_records: [
              cname,
            ],
          }
        }
      }
    end

    def cname
      if endpoint_types.include?("REGIONAL")
        "!GetAtt DomainName.RegionalDomainName"
      else
        "!GetAtt DomainName.DistributionDomainName"
      end
    end

    def domain_name
      Jets::Resource::ApiGateway::DomainName.new
    end
    memoize :domain_name

    def endpoint_types
      domain_name.endpoint_types
    end

    # IE: demo-dev.mydomain.com
    def name
      # Weird looking but correct: domain_name is object and domain_name is also method
      domain_name.domain_name
    end

    # IE: mydomain.com
    def hosted_zone_name
      name = Jets.config.domain.hosted_zone_name
      name.ends_with?('.') ? name : "#{name}." # add trailing period if missing
    end

    def outputs
      {
        "DnsRecord" => "!Ref DnsRecord",
      }
    end
  end
end

Version data entries

130 entries across 130 versions & 3 rubygems

Version Path
jets-1.5.5 lib/jets/resource/route53/record_set.rb
jets-1.5.4 lib/jets/resource/route53/record_set.rb
jets-1.5.3 lib/jets/resource/route53/record_set.rb
jets-1.5.2 lib/jets/resource/route53/record_set.rb
jets-1.5.1 lib/jets/resource/route53/record_set.rb
jets-1.5.0 lib/jets/resource/route53/record_set.rb
jets-1.4.11 lib/jets/resource/route53/record_set.rb
jets-1.4.10 lib/jets/resource/route53/record_set.rb
jets-1.4.9 lib/jets/resource/route53/record_set.rb
jets-1.4.8 lib/jets/resource/route53/record_set.rb
jets-1.4.7 lib/jets/resource/route53/record_set.rb
jets-1.4.6 lib/jets/resource/route53/record_set.rb
jets-1.4.5 lib/jets/resource/route53/record_set.rb
jets-1.4.4 lib/jets/resource/route53/record_set.rb
jets-1.4.3 lib/jets/resource/route53/record_set.rb
jets-1.4.2 lib/jets/resource/route53/record_set.rb
jets-1.4.1 lib/jets/resource/route53/record_set.rb
jets-1.4.0 lib/jets/resource/route53/record_set.rb
jets-1.3.9 lib/jets/resource/route53/record_set.rb
jets-1.3.8 lib/jets/resource/route53/record_set.rb