AWS:获取Route53 HostedZone名称

时间:2018-05-26 12:52:08

标签: amazon-web-services amazon-cloudformation

我将一组记录添加到来自云形成的route53,这是代码

 "RDSDNSRecord" : {
      "Type" : "AWS::Route53::RecordSet",
      "Properties" : {

         "HostedZoneId" : { "Ref" : "DNSZoneId" },
         "Comment" : "DNS name for RDS",  
         "Name" : { "Fn::Join" : [ "", [ {  "Ref": "EnvType"}, "." ,"rds",".",{"Ref" : "AWS::Region"} ,".",{"Ref" : "HostedZone"},"." ] ] },
         "Type" : "CNAME",
         "TTL" : "900",
         "ResourceRecords" : [
           {
            "Ref": "DatabaseEndPoint"
         }
         ]
      }
   }
之前已经创建了

和HostedZones。所以为了设置这些记录我使用这些参数。

"DNSZoneId":{
         "Type" :"AWS::Route53::HostedZone::Id",
         "ConstraintDescription":"must be the name of an existing ZoneId"
      },
      "HostedZone":{
         "Type": "String",
          "Description":"Relavent Domain Name"
      }

aws要求将完全限定的域名传递给参数Name。所以我问用户的DomainName和ZoneId。我觉得问ID和名字都不对。有没有办法从zoneId或任何变通方法获取名称?

1 个答案:

答案 0 :(得分:0)

HostedZoneId是可选的,您也可以使用HostedZoneName

  

HostedZoneId托管区域的ID。

     

必需:有条件。您必须指定HostedZoneName或   HostedZoneId,但你不能同时指定。如果此记录集是一部分   对于记录集组,请不要指定此属性。