fixed route53 private zone value (#4935)
This commit is contained in:
parent
c1c423674c
commit
0ed34cbe7e
@ -524,7 +524,7 @@ class Route53Backend(BaseBackend):
|
|||||||
"""
|
"""
|
||||||
zone_list = []
|
zone_list = []
|
||||||
for zone in self.list_hosted_zones():
|
for zone in self.list_hosted_zones():
|
||||||
if zone.private_zone == "true":
|
if zone.private_zone is True:
|
||||||
this_zone = self.get_hosted_zone(zone.id)
|
this_zone = self.get_hosted_zone(zone.id)
|
||||||
if this_zone.vpcid == vpc_id:
|
if this_zone.vpcid == vpc_id:
|
||||||
this_id = f"/hostedzone/{zone.id}"
|
this_id = f"/hostedzone/{zone.id}"
|
||||||
|
@ -26,6 +26,16 @@ def error_handler(f):
|
|||||||
class Route53(BaseResponse):
|
class Route53(BaseResponse):
|
||||||
"""Handler for Route53 requests and responses."""
|
"""Handler for Route53 requests and responses."""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _convert_to_bool(bool_str):
|
||||||
|
if isinstance(bool_str, bool):
|
||||||
|
return bool_str
|
||||||
|
|
||||||
|
if isinstance(bool_str, str):
|
||||||
|
return str(bool_str).lower() == "true"
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
@error_handler
|
@error_handler
|
||||||
def list_or_create_hostzone_response(self, request, full_url, headers):
|
def list_or_create_hostzone_response(self, request, full_url, headers):
|
||||||
self.setup_class(request, full_url, headers)
|
self.setup_class(request, full_url, headers)
|
||||||
@ -40,14 +50,19 @@ class Route53(BaseResponse):
|
|||||||
if "HostedZoneConfig" in zone_request:
|
if "HostedZoneConfig" in zone_request:
|
||||||
zone_config = zone_request["HostedZoneConfig"]
|
zone_config = zone_request["HostedZoneConfig"]
|
||||||
comment = zone_config["Comment"]
|
comment = zone_config["Comment"]
|
||||||
private_zone = zone_config.get("PrivateZone", False)
|
if zone_request.get("VPC", {}).get("VPCId", None):
|
||||||
|
private_zone = True
|
||||||
|
else:
|
||||||
|
private_zone = self._convert_to_bool(
|
||||||
|
zone_config.get("PrivateZone", False)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
comment = None
|
comment = None
|
||||||
private_zone = False
|
private_zone = False
|
||||||
|
|
||||||
# It is possible to create a Private Hosted Zone without
|
# It is possible to create a Private Hosted Zone without
|
||||||
# associating VPC at the time of creation.
|
# associating VPC at the time of creation.
|
||||||
if private_zone == "true":
|
if self._convert_to_bool(private_zone):
|
||||||
if zone_request.get("VPC", None) is not None:
|
if zone_request.get("VPC", None) is not None:
|
||||||
vpcid = zone_request["VPC"].get("VPCId", None)
|
vpcid = zone_request["VPC"].get("VPCId", None)
|
||||||
vpcregion = zone_request["VPC"].get("VPCRegion", None)
|
vpcregion = zone_request["VPC"].get("VPCRegion", None)
|
||||||
@ -500,7 +515,7 @@ GET_HOSTED_ZONE_RESPONSE = """<GetHostedZoneResponse xmlns="https://route53.amaz
|
|||||||
{% if zone.comment %}
|
{% if zone.comment %}
|
||||||
<Comment>{{ zone.comment }}</Comment>
|
<Comment>{{ zone.comment }}</Comment>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<PrivateZone>{{ zone.private_zone }}</PrivateZone>
|
<PrivateZone>{{ 'true' if zone.private_zone else 'false' }}</PrivateZone>
|
||||||
</Config>
|
</Config>
|
||||||
</HostedZone>
|
</HostedZone>
|
||||||
<DelegationSet>
|
<DelegationSet>
|
||||||
@ -527,7 +542,7 @@ CREATE_HOSTED_ZONE_RESPONSE = """<CreateHostedZoneResponse xmlns="https://route5
|
|||||||
{% if zone.comment %}
|
{% if zone.comment %}
|
||||||
<Comment>{{ zone.comment }}</Comment>
|
<Comment>{{ zone.comment }}</Comment>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<PrivateZone>{{ zone.private_zone }}</PrivateZone>
|
<PrivateZone>{{ 'true' if zone.private_zone else 'false' }}</PrivateZone>
|
||||||
</Config>
|
</Config>
|
||||||
</HostedZone>
|
</HostedZone>
|
||||||
<DelegationSet>
|
<DelegationSet>
|
||||||
@ -552,7 +567,7 @@ LIST_HOSTED_ZONES_RESPONSE = """<ListHostedZonesResponse xmlns="https://route53.
|
|||||||
{% if zone.comment %}
|
{% if zone.comment %}
|
||||||
<Comment>{{ zone.comment }}</Comment>
|
<Comment>{{ zone.comment }}</Comment>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<PrivateZone>{{ zone.private_zone }}</PrivateZone>
|
<PrivateZone>{{ 'true' if zone.private_zone else 'false' }}</PrivateZone>
|
||||||
</Config>
|
</Config>
|
||||||
<ResourceRecordSetCount>{{ zone.rrsets|count }}</ResourceRecordSetCount>
|
<ResourceRecordSetCount>{{ zone.rrsets|count }}</ResourceRecordSetCount>
|
||||||
</HostedZone>
|
</HostedZone>
|
||||||
@ -574,7 +589,7 @@ LIST_HOSTED_ZONES_BY_NAME_RESPONSE = """<ListHostedZonesByNameResponse xmlns="{{
|
|||||||
{% if zone.comment %}
|
{% if zone.comment %}
|
||||||
<Comment>{{ zone.comment }}</Comment>
|
<Comment>{{ zone.comment }}</Comment>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<PrivateZone>{{ zone.private_zone }}</PrivateZone>
|
<PrivateZone>{{ 'true' if zone.private_zone else 'false' }}</PrivateZone>
|
||||||
</Config>
|
</Config>
|
||||||
<ResourceRecordSetCount>{{ zone.rrsets|count }}</ResourceRecordSetCount>
|
<ResourceRecordSetCount>{{ zone.rrsets|count }}</ResourceRecordSetCount>
|
||||||
</HostedZone>
|
</HostedZone>
|
||||||
|
Loading…
Reference in New Issue
Block a user