简体   繁体   English

Boto3和Moto-创建DNS记录集的Route53错误,找不到托管区域

[英]Boto3 & moto - Route53 error creating dns record set, it can't find the hosted zone

I am having some troubles with Boto3 and the moto library for mocking AWS. 我在Boto3和moto库中遇到了一些麻烦,无法模拟AWS。

I am creating a hosted zone like this: 我正在创建一个托管区域,如下所示:

@moto.mock_route53
def create_dns_zone(route53_client, vpc, name='test.'):
    hosted_zone = route53_client.create_hosted_zone(
        Name=name,
        VPC={'VPCId': vpc.vpc_id},
        CallerReference=str(hash('test')),
        HostedZoneConfig=dict(
            PrivateZone=True,
            Comment="testing zone",
        )
    )
    return hosted_zone

The vpc object and the route53_client object are created in the same region. vpc对象和route53_client对象在同一区域中创建。 And I changed some properties of the vpc object like this: 我更改了vpc对象的某些属性,如下所示:

ec2.modify_vpc_attribute(
    EnableDnsHostnames={'Value': True}, EnableDnsSupport={'Value': True}, VpcId=vpc.vpc_id
)

The create_dns_zone function returns this object: create_dns_zone函数返回此对象:

托管区域

And then I try to create the dns registry in AWS: 然后,我尝试在AWS中创建dns注册表:

@moto.mock_route53
def create_dns(client_route53, zones, total_dns=1):
    # zones is the hosted zone object    
    hosted_zone_id = session.get_hosted_zone(Id=zones.get('HostedZone').get('Id'))

    changes_dns = []
    for index in range(total_dns):
        index += 1
        data_dns = dict(
            Action='CREATE',
            ResourceRecordSet=dict(
                Name='dns-test.{index}.testing.internal'.format(index=index),
                Type='A',
                TTL=30,
                ResourceRecords=[{'Value': '10.10.0.1{index}'.format(index)}]
            )
        )
        changes_dns.append(data_dns)

    return client_route53.change_resource_record_sets(
        HostedZoneId=hosted_zone_id,
        ChangeBatch=dict(
            Comment='testing dns',
            Changes=changes_dns
        )
    )

So when I want to create an entry in the route53 dns server names it throws this exception: 因此,当我想在route53 dns服务器名称中创建一个条目时,它将引发此异常:

Exception: An error occurred (404) when calling the GetHostedZone operation: Not Found

And scrolling down in the error log: 并向下滚动到错误日志:

botocore.parsers.ResponseParserError: Unable to parse response (syntax error: line 1, column 0), invalid XML received: b'Zone VINSTS51LDMLEAA not Found' And if I call the function list_hosted_zones() it returns an empty list. botocore.parsers.ResponseParserError: Unable to parse response (syntax error: line 1, column 0), invalid XML received: b'Zone VINSTS51LDMLEAA not Found' ,如果我调用函数list_hosted_zones()它将返回一个空列表。

Did I do something wrong? 我做错什么了吗? Or miss anything? 还是错过任何事情?

Thank you so much. 非常感谢。

The moto AWS mock implementation doesn't have 100% coverage. moto AWS模拟实现没有100%的覆盖率。 In this case, route53 only is 12% implemented . 在这种情况下,仅实现了 53 %的 route53。 I think this is your problem. 我认为这是您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM