2
votes

Trying to deploy a CFT that contains a Route53::RecordSet Resource. This is the error I get.

Tried to create an alias that targets \052., type A in zone Z1UJRXOUMOOFQ8, but the alias target name does not lie within the target zone

This is my CFT template for my Record Set Resource

DnsGateway:
    Type: AWS::Route53::RecordSet
    Properties:
      Comment: DNS for custom domain endpoint
      HostedZoneId:
        Fn::ImportValue: !Sub "dns-${Environment}-HostedZoneId"
      AliasTarget:
        DNSName: 
          !Ref RegionalDomainName 
        HostedZoneId: 
          !FindInMap [ RegionMap, !Ref "AWS::Region", HostedZoneId ]
        EvaluateTargetHealth: true
      Name: 
        Fn::Join:
          - "."
          - - Example
            - Fn::ImportValue: !Sub "dns-${Environment}-SubZoneDomain"
      Type: A
      Region: !Ref AWS::Region
      SetIdentifier: !Sub "Example-API-RS-${Environment}-${AWS::Region}"
1
Minor FormattingAurelius Prochazka

1 Answers

1
votes

You receive this error when your aliasTarget is missconfigured, here I can see that your DNSName and HostedZoneId has wrong value:

You can find these value needed in attributes of your custom domain.

Assuming your RegionalDomainName is a ressource of type AWS::ApiGateway::DomainName

you can configure your alias target using attributes of RegionalDomainName like this :

  AliasTarget:
    DNSName: 
      Fn::GetAtt: [ RegionalDomainName, RegionalDomainName] 
    HostedZoneId: 
      Fn::GetAtt: [ RegionalDomainName, RegionalHostedZoneId]
    EvaluateTargetHealth: true

PS: Use Ref on RegionalDomainName give the domain name you configure wich is not the same as the regional domain name provided by AWS