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
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)