I am having some troubles with Boto3 and the moto library for mocking 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. And I changed some properties of the vpc object like this:
ec2.modify_vpc_attribute(
EnableDnsHostnames={'Value': True}, EnableDnsSupport={'Value': True}, VpcId=vpc.vpc_id
)
The create_dns_zone
function returns this object:
And then I try to create the dns registry in AWS:
@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:
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.
Did I do something wrong? Or miss anything?
Thank you so much.
The moto AWS mock implementation doesn't have 100% coverage. In this case, route53 only is 12% implemented. I think this is your problem.