You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取Serverless生成的CloudFront域名以配置Route53自定义域名

Got it, let's break down how to get that CloudFront domain name so you can set up your Route53 record for api.example.com. Here are a few straightforward ways:

获取Serverless部署生成的CloudFront域名的几种方法

1. 查看Serverless部署/info命令输出

When you run serverless deploy in your terminal, the final output will list key resources created by the deployment—including the CloudFront domain name. Look for a line like:

CloudFront Domain Name: d12345abcdefg.cloudfront.net

If you missed it during deployment, just run serverless info afterward. This command gives a clean summary of your deployed stack, and the CloudFront domain will be front and center in the resource list.

2. Find it via the AWS Console

If you prefer a visual approach:

  • Log into the AWS Console and navigate to the CloudFront service
  • In the distributions list, look for the one linked to your Serverless API (you can identify it by checking the origin—this will be your API Gateway's domain)
  • Click into the distribution, and on the Overview tab, you'll see the "Domain Name" field—this is exactly what you need

To make this easier every time you deploy, add an output block to your serverless.yml. This ensures the CloudFront domain is always clearly displayed after deployment:

resources:
  Outputs:
    ApiCloudFrontDomain:
      Value: !GetAtt CloudFrontDistribution.DomainName
      Description: CloudFront domain name for the Serverless API

Note: Replace CloudFrontDistribution with the actual name of your CloudFront resource in the Serverless config (if you didn't customize it, the default name might look like WebAppCloudFrontDistribution).

4. Query with AWS CLI

If you're comfortable with command-line tools, use the AWS CLI to filter and fetch the domain:

aws cloudfront list-distributions --query "DistributionList.Items[?Origins.Items[0].DomainName contains 'execute-api']" --output json

This command filters CloudFront distributions linked to API Gateway (via the execute-api string in the origin domain). The returned JSON will include the DomainName field for matching distributions. You can narrow it down further by adding filters for the distribution's comment or tags if needed.

Once you have the CloudFront domain, head over to Route53 and create a CNAME record pointing api.example.com to that domain.

内容的提问来源于stack exchange,提问作者Daniel Birowsky Popeski

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 08:00:50