Skip to content

Commit de43d79

Browse files
committed
code refactor
1 parent d0bd5d4 commit de43d79

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

samtranslator/model/api/api_generator.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -515,29 +515,28 @@ def _construct_api_domain(self, rest_api):
515515
record_set_group = None
516516
if self.domain.get("Route53") is not None:
517517
route53 = self.domain.get("Route53")
518-
if isinstance(route53, dict):
519-
if route53.get("HostedZoneId") is None and route53.get("HostedZoneName") is None:
520-
raise InvalidResourceException(
521-
self.logical_id,
522-
"HostedZoneId or HostedZoneName is required to enable Route53 support on Custom Domains.",
523-
)
524-
logical_id = logical_id_generator.LogicalIdGenerator(
525-
"", route53.get("HostedZoneId") or route53.get("HostedZoneName")
526-
).gen()
527-
record_set_group = Route53RecordSetGroup(
528-
"RecordSetGroup" + logical_id, attributes=self.passthrough_resource_attributes
529-
)
530-
if "HostedZoneId" in route53:
531-
record_set_group.HostedZoneId = route53.get("HostedZoneId")
532-
if "HostedZoneName" in route53:
533-
record_set_group.HostedZoneName = route53.get("HostedZoneName")
534-
record_set_group.RecordSets = self._construct_record_sets_for_domain(self.domain)
535-
else:
518+
if not isinstance(route53, dict):
536519
raise InvalidResourceException(
537520
self.logical_id,
538521
"Invalid property type '{}' for Route53. "
539522
"Expected a map defines an Amazon Route 53 configuration'.".format(type(route53).__name__),
540523
)
524+
if route53.get("HostedZoneId") is None and route53.get("HostedZoneName") is None:
525+
raise InvalidResourceException(
526+
self.logical_id,
527+
"HostedZoneId or HostedZoneName is required to enable Route53 support on Custom Domains.",
528+
)
529+
logical_id = logical_id_generator.LogicalIdGenerator(
530+
"", route53.get("HostedZoneId") or route53.get("HostedZoneName")
531+
).gen()
532+
record_set_group = Route53RecordSetGroup(
533+
"RecordSetGroup" + logical_id, attributes=self.passthrough_resource_attributes
534+
)
535+
if "HostedZoneId" in route53:
536+
record_set_group.HostedZoneId = route53.get("HostedZoneId")
537+
if "HostedZoneName" in route53:
538+
record_set_group.HostedZoneName = route53.get("HostedZoneName")
539+
record_set_group.RecordSets = self._construct_record_sets_for_domain(self.domain)
541540

542541
return domain, basepath_resource_list, record_set_group
543542

0 commit comments

Comments
 (0)