Search code examples
amazon-web-servicesaws-cloudformationamazon-cloudfrontamazon-route53

How to create record in route53 hostedZone


I have created CloudFront distribution and trying to attach that record to the route53 hosted zone. when I'm trying it is giving below error.

An error occurred: myDNSRecord - Invalid request: Expected exactly one of [AliasTarget, all of [TTL, and ResourceRecords], or TrafficPolicyInstanceId], but found none in Change with [Action=CREATE, Name=abc.yz.com., Type=A, SetIdentifier=null] (Service: AmazonRoute53; Status Code: 400; Error Code: InvalidInput; Request ID: 81fd7f48-3ffb-4fa1-b1ba-cef599834a07; Proxy: null)

myDNSRecord:
      Type: AWS::Route53::RecordSetGroup
      DependsOn:
        - cloudFrontDist
      Properties:
        HostedZoneId: !Ref 53HostedZoneId
        RecordSets:
          - Name: abc.yz.com
            Type: A
            TTL: 300
            AliasTarget:
              HostedZoneId: Z2FDTNDATAQYW2
              DNSName:
                Fn::GetAtt: [cloudFrontDist, DomainName]

I want to host the CloudFront distribution URL in route53


Solution

  • Alias records don't use TTL. So remove it from your template:

    myDNSRecord:
          Type: AWS::Route53::RecordSetGroup
          DependsOn:
            - cloudFrontDist
          Properties:
            HostedZoneId: !Ref 53HostedZoneId
            RecordSets:
              - Name: abc.yz.com
                Type: A
                AliasTarget:
                  HostedZoneId: Z2FDTNDATAQYW2
                  DNSName:
                    Fn::GetAtt: [cloudFrontDist, DomainName]