Cloudformation: Requested attribute DistributionHostedZoneId does not exist in schema for AWS::CloudFront::Distribution

0

Hollo Please i get this error when i want to get my Cloudfront Distribution Hosted Zone ID

Error

Requested attribute DistributionHostedZoneId does not exist in schema for AWS::CloudFront::Distribution

My CloudFormation Template

  FESCloudFrontDistributionDomainNameRecord:
    Type: AWS::Route53::RecordSet # Defines a Route 53 record set
    Properties:
      # HostedZoneName: !Sub "${CustomDomainName}."
      HostedZoneId: !Ref CustomDomainHostedZoneID
      Name: !Sub "${CustomDomainName}." # Specifies the record name
      Type: A # Specifies the record type as A
      AliasTarget:
        HostedZoneId: !GetAtt FECloudFrontDistribution.DistributionHostedZoneId
        DNSName: !GetAtt FECloudFrontDistribution.DomainName 

Thanks

1 Answer
1
Accepted Answer

Hello.
Try changing "HostedZoneId" to "Z2FDTNDATAQYW2" as described in the following document.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-route53.html#w4ab1c23c21c84c11

When you create alias resource record sets, you must specify Z2FDTNDATAQYW2 for the HostedZoneId property, as shown in the following example. Alias resource record sets for CloudFront can't be created in a private zone.

Your template would look something like this

  FESCloudFrontDistributionDomainNameRecord:
    Type: AWS::Route53::RecordSet # Defines a Route 53 record set
    Properties:
      # HostedZoneName: !Sub "${CustomDomainName}."
      HostedZoneId: !Ref CustomDomainHostedZoneID
      Name: !Sub "${CustomDomainName}." # Specifies the record name
      Type: A # Specifies the record type as A
      AliasTarget:
        HostedZoneId: Z2FDTNDATAQYW2
        DNSName: !GetAtt FECloudFrontDistribution.DomainName 
profile picture
EXPERT
answered a year ago
profile picture
EXPERT
reviewed a year ago
profile pictureAWS
EXPERT
reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions