How to get the CloudFront distribution's domain name

The goal is to create a custom domain for my Serverless api: So my approach is to create this Route53 record:

  Type: AWS::Route53::RecordSet
    Type: A
    HostedZoneId: Z2PERRPAZRTJGB
      HostedZoneId: Z2FDTNDATAQYW2
        Fn::GetAtt: [ --> what do we enter here <--, DomainName ]

But how do I provide the domain name from the CloudFront emitted by Serverless?

I am aware about the serverless-domain-manager plugin, but I don’t like how it’s not completely declarative. How It want’s me to run a command at some point. That’s why I’m turning to CloudFormation for this one.

Were you able to get this figured out? If so, would you share your solution? I’m running into the same problem.

Have you created the distribution in the same serverless configuration? If you have the cloudfront distribution definition in your template such as

    Type: "AWS::CloudFront::Distribution"

You can use

  - MyCloudfrontDistribution
  - DomainName

You refer to the resource you created for your distribution i.e. in this case, MyCloudfrontDistribution

If you didn’t create the distribution in this cloudformation (albeit within serverless) template you can output the value in your other template, then retrieve the value using Fn::ImportValue: