我们正在使用AWS API Gateway,而我正在使用CloudFormation来注册域和A记录,如下所示:
Domain:
Type: AWS::ApiGateway::DomainName
Properties:
# EnvironmentName starts with an upper case letter, but the domain is created anyway
DomainName: !Sub "${EnvironmentName}.mycompany.com"
# this is a single certificate, used for all envs, and must be in virginia
CertificateArn: !ImportValue DomainCertificateArn
SecurityPolicy: TLS_1_2
EndpointConfiguration:
Types:
- EDGE
ARecord:
Type: AWS::Route53::RecordSet
Properties:
HostedZoneId: Fn::ImportValue !Sub "${EnvironmentName}-HostedZoneId"
# resolves to Z032215012YHJZINBEW
Type: A
Name: !Ref Domain
AliasTarget:
DNSName: !GetAtt Domain.DistributionDomainName
HostedZoneId: !GetAtt Domain.DistributionHostedZoneId
但是,在我的环境中运行此错误时,我看到以下错误:
Unable to retrieve DistributionHostedZoneId attribute for AWS::ApiGateway::DomainName
我已经在API Gateway控制台中检查了该域条目,并且该域条目确实存在,其类型为EDGE,并且存在所有其他参数。但是,“托管区域ID”与模板中使用的值不同。
答案 0 :(得分:0)
根据documentation,您应该能够从AWS::ApiGateway::DomainName资源的distributionHostedZoneId
属性中获取此值。
根据文档和您的文件,似乎没有任何配置错误,文档中还有关于DistributionHostedZoneId
的这一行。
The only valid value is Z2FDTNDATAQYW2 for all regions.
这是CloudFront发行ID(在您使用区域时),因此您可以专门设置此值。否则,请验证它是否被创建为EDGE
自定义域。