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 réponse
1
Réponse acceptée

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
répondu il y a 9 mois
profile picture
EXPERT
vérifié il y a 9 mois
profile pictureAWS
EXPERT
vérifié il y a 9 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions