dptgpyl61857413 2015-10-24 19:16
浏览 176
已采纳

AWS Route 53 - 按域名获取托管区域?

Is there a way to retrieve a Hosted Zone by Domain Name ?

I thought using listHostedZonesByName( 'pagefoo.io' ) would do the trick, but it returns unrelated results: pagefoo.net, pagefoo.org instead of just pagefoo.io.

Array
(
    [0] => Array
        (
            [Id] => /hostedzone/XXXXXXXXXXXX
            [Name] => pagefoo.io.
            [CallerReference] => XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
            [Config] => Array
                (
                    [PrivateZone] => 
                )

            [ResourceRecordSetCount] => 5
        )

    [1] => Array
        (
            [Id] => /hostedzone/XXXXXXXXXXXX
            [Name] => pagefoo.net.
            [CallerReference] => XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
            [Config] => Array
                (
                    [PrivateZone] => 
                )

            [ResourceRecordSetCount] => 6
        )

    [2] => Array
        (
            [Id] => /hostedzone/XXXXXXXXXXXX
            [Name] => pagefoo.org.
            [CallerReference] => XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
            [Config] => Array
                (
                    [PrivateZone] => 
                )

            [ResourceRecordSetCount] => 4
        )

)
  • 写回答

1条回答 默认 最新

  • doumu4916 2015-10-24 21:04
    关注

    Using the aws-cli route53 interface, I called list-hosted-zones-by-name. It returned all of my zones.

    $ aws route53 list-hosted-zones-by-name
    {
        "HostedZones": [
            (lots of output here)
        ], 
        "IsTruncated": false, 
        "MaxItems": "100"
    }
    

    I then added --dns-name domain.com to the query and it returned the one result as I expected:

    $ aws route53 list-hosted-zones-by-name --dns-name domain.com
    {
        "HostedZones": [
            {
                "ResourceRecordSetCount": 7, 
                "CallerReference": "12345abcde", 
                "Config": {
                    "Comment": "HostedZone created by Route53 Registrar", 
                    "PrivateZone": false
                }, 
                "Id": "/hostedzone/AABBCCDD", 
                "Name": "domain.com."
            }
        ], 
        "DNSName": "domain.com", 
        "IsTruncated": false, 
        "MaxItems": "100"
    }
    

    You didn't say what language you are using, but the calls are all similar, since it's an API response. If you need help with a specific SDK you should include the language and the code for calling it. But assuming your output is from Javascript, it looks like this is the proper call:

    route53.listHostedZonesByName({ DNSName: 'domain.com' }, function(err, data) {
      if (err) console.log(err, err.stack); // an error occurred
      else     console.log(data);           // successful response
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘