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-2.1.5 lib/jets/resource/route53/record_set.rb
jets-2.1.4 lib/jets/resource/route53/record_set.rb
jets-2.1.3 lib/jets/resource/route53/record_set.rb
jets-2.1.2 lib/jets/resource/route53/record_set.rb
jets_bb_fork-0.0.4 lib/jets/resource/route53/record_set.rb
jets-2.1.1 lib/jets/resource/route53/record_set.rb
jets-2.1.0 lib/jets/resource/route53/record_set.rb
jets-2.0.6 lib/jets/resource/route53/record_set.rb
jets-2.0.5 lib/jets/resource/route53/record_set.rb
jets-2.0.4 lib/jets/resource/route53/record_set.rb
jets-2.0.3 lib/jets/resource/route53/record_set.rb
jets-2.0.1 lib/jets/resource/route53/record_set.rb
jets-2.0.0 lib/jets/resource/route53/record_set.rb
jets-1.9.32 lib/jets/resource/route53/record_set.rb
jets-1.9.31 lib/jets/resource/route53/record_set.rb
jets-1.9.30 lib/jets/resource/route53/record_set.rb
jets-1.9.29 lib/jets/resource/route53/record_set.rb
jets-1.9.28 lib/jets/resource/route53/record_set.rb
jets-1.9.27 lib/jets/resource/route53/record_set.rb
jets-1.9.26 lib/jets/resource/route53/record_set.rb