Skip to content

Commit

Permalink
[INFRA-2155] Removing function to create HZ
Browse files Browse the repository at this point in the history
  • Loading branch information
vitali-federau-fivestars committed Nov 22, 2023
1 parent b35578a commit 3e4d321
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions aladdin/lib/aws/dns_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ def fill_hostedzone(
):
cluster_domain_name = cluster_domain_name or ClusterRules().cluster_domain_name
namespace_domain_name = namespace_domain_name or ClusterRules().namespace_domain_name
namespace_hosted_zone = get_hostedzone(
boto_session, namespace_domain_name
) or create_hostedzone(boto_session, namespace_domain_name)

# Get the namespace hosted zone, raise an error if not found
namespace_hosted_zone = get_hostedzone(boto_session, namespace_domain_name)
if namespace_hosted_zone is None:
raise KeyError("Hosted zone for [%s] not found" % namespace_domain_name)

# Get the cluster hosted zone, raise an error if not found
cluster_hosted_zone = get_hostedzone(boto_session, cluster_domain_name)
if cluster_hosted_zone is None:
raise KeyError("route 53 for [%s] not found" % cluster_domain_name)
raise KeyError("Route 53 for [%s] not found" % cluster_domain_name)

dns_nameservers = get_ns_from_hostedzone(boto_session, namespace_hosted_zone)

Expand Down Expand Up @@ -48,24 +51,6 @@ def get_hostedzone(boto_session, dns_name) -> str:
return hostedzone_id


def create_hostedzone(boto_session, dns_name) -> str:
log = logging.getLogger(__name__)
route53 = boto_session.client("route53")

ref = "aladdin_generated_{:%Y%m%d_%H%M%S}".format(datetime.now())

log.info("Hosted zone %s created", dns_name)

log.info("Creating hosted zone : %s", dns_name)
create_res = route53.create_hosted_zone(
Name=dns_name,
CallerReference=ref,
HostedZoneConfig=dict(Comment="Generated by aladdin", PrivateZone=False),
)

return create_res["HostedZone"]["Id"]


def get_ns_from_hostedzone(boto_session, hostedzone_id):
route53 = boto_session.client("route53")

Expand Down

0 comments on commit 3e4d321

Please sign in to comment.