我正在尝试在 AWS 上创建一个多区域无服务器应用程序。我已按照此处给出的说明进行操作。我正在使用无服务器框架,它使用 Cloudformation 脚本在 AWS 上创建所有资源。
我想为 API 网关创建一个自定义域作为区域端点。当它创建一个区域端点时,它会生成一个目标域。我想知道如何在我的 Cloudformation 脚本中获取目标域的值?
当我创建边缘优化终端节点时,我通过使用DistributionDomainName
属性获取 CloudFront 部署的值。但是在创建区域端点时,我没有看到目标域名的任何属性。我尝试将DistributionDomainName
属性用于区域端点,但它会抛出一个错误,指出没有DistributionDomainName
.
以下是我的脚本的一部分 -
# Creates a custom domain for the ApiGateway
customDomain:
Type: 'AWS::ApiGateway::DomainName'
Properties:
DomainName: ${self:custom.domain}
EndpointConfiguration:
Types:
- REGIONAL
RegionalCertificateArn: ${self:custom.certificateArn}
# Insert a DNS record in route53 hosted zone to redirect from the custom domain to CF distribution
dnsRecord:
Type: AWS::Route53::RecordSet
Properties:
Region: ${self:provider.region}
SetIdentifier: ${self:provider.region}
HostedZoneId: ${self:custom.hostedZoneId}
Name: ${self:custom.domain}
Type: CNAME
TTL: 60
ResourceRecords:
- "Fn::GetAtt": [customDomain, DistributionDomainName]
请帮忙。谢谢!
更新
RegionalDomainName
Cloudformation 现在通过属性返回区域域名。它可以用作Fn:GetAtt : [customDomain, RegionalDomainName]
.