Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Apr 29, 2023
1 parent f8ce60c commit 04fa566
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions code/ddns-lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,16 +802,17 @@ def lambda_handler(
# Get the PHZ ID for the Zone
zone_forward_item = phz_collection_by_vpc.get(final_hosted_zone_name, {})
if zone_forward_item:
zone_data_forward = zone_data_tuple(
*phz_collection_by_vpc[final_hosted_zone_name].values())
zone_data_forward = zone_data_tuple(
*phz_collection_by_vpc[final_hosted_zone_name].values())
else:
zone_data_forward = zone_data_tuple(None, None, None, None, None)
zone_data_forward = zone_data_tuple(None, None, None, None, None)

zone_reverse_item = phz_collection_by_vpc.get(tag_data['ptr_entry'].zonename], {})
zone_reverse_item = phz_collection_by_vpc.get(tag_data['ptr_entry'].zonename, {})
if zone_reverse_item:
zone_data_reverse = zone_data_tuple(*phz_collection_by_vpc[tag_data['ptr_entry'].zonename].values())
zone_data_reverse = zone_data_tuple(
*phz_collection_by_vpc[tag_data['ptr_entry'].zonename].values())
else:
zone_data_reverse = zone_data_tuple(None, None, None, None, None)
zone_data_reverse = zone_data_tuple(None, None, None, None, None)

# final_hosted_zone_item = phz_collection_by_vpc[final_hosted_zone_name]
# final_hosted_zone_id = zone_data_forward.zone_id
Expand All @@ -824,7 +825,7 @@ def lambda_handler(
f"private_hosted_zone: zone_id {zone_data_forward.zone_id} is_mine {zone_data_forward.owner_account==account_id} owner {zone_data_forward.owner_account}: {lineno()}")

# create the TXT heritage record
heritage=initialize_heritage(HERITAGE_TAG, VERSION,
heritage = initialize_heritage(HERITAGE_TAG, VERSION,
{
'account_id': account_id,
'region': region,
Expand Down Expand Up @@ -910,12 +911,12 @@ def lambda_handler(
LOGGER.error("instance: %s, unexpected error. %s\n",
instance_id, str(err) + lineno())
else:
if not zone_data_forward.zone_id:
LOGGER.info(
f"not adding A and heritage TXT for host {final_private_hostname} zone {zone_data_forward.name} no such zone value {private_ip}")
else:
LOGGER.info(
f"flags=noforward, not adding A and heritage TXT for host {final_private_hostname} zone {zone_data_forward.name} value {private_ip}")
if not zone_data_forward.zone_id:
LOGGER.info(
f"not adding A and heritage TXT for host {final_private_hostname} zone {zone_data_forward.name} no such zone value {private_ip}")
else:
LOGGER.info(
f"flags=noforward, not adding A and heritage TXT for host {final_private_hostname} zone {zone_data_forward.name} value {private_ip}")

if not flags['notpr'] and zone_data_reverse.zone_id:
# fqdn = create_fqdn(final_private_hostname, final_hosted_zone_name)
Expand Down Expand Up @@ -986,11 +987,11 @@ def lambda_handler(
instance_id, str(err) + lineno())
else:
if not zone_data_reverse.zone_id:
LOGGER.info(
f"not adding PTR and heritage TXT for host {tag_data['ptr_entry'].hostname} zone {tag_data['ptr_entry'].zonename} no such zone value {final_private_dns_name}")
LOGGER.info(
f"not adding PTR and heritage TXT for host {tag_data['ptr_entry'].hostname} zone {tag_data['ptr_entry'].zonename} no such zone value {final_private_dns_name}")
else:
LOGGER.info(
f"flags=noptr, not adding PTR and heritage TXT for host {tag_data['ptr_entry'].hostname} zone {tag_data['ptr_entry'].zonename} value {final_private_dns_name}")
LOGGER.info(
f"flags=noptr, not adding PTR and heritage TXT for host {tag_data['ptr_entry'].hostname} zone {tag_data['ptr_entry'].zonename} value {final_private_dns_name}")

# else: # not running so delete the records. Note this may leave orphans around if the flags are set and then the host is shut down. We may want to remove no matter what.
# go through the dns_data records, and delete them. dns_data contains the records that were added. It is possible the tags have changed
Expand Down Expand Up @@ -1026,11 +1027,11 @@ def lambda_handler(
# cname_domain_suffix_id = cname_domain_suffix_item['zone_id']
# LOGGER.debug("cname_domain_suffix_id: %s", str(cname_domain_suffix_id))

cf_zonename_item = phz_collection_by_vpc.get(cf_zonename,None)
cf_zonename_item = phz_collection_by_vpc.get(cf_zonename, None)
if cf_zonename_item:
cf_zonename_id = cf_zonename_item['zone_id']
cf_zonename_id = cf_zonename_item['zone_id']
else:
cf_zonename_id = None
cf_zonename_id = None
LOGGER.debug(f"cname_domain_suffix_id: {cf_zonename_id}")

# create CNAME record in private zone
Expand Down Expand Up @@ -3095,8 +3096,7 @@ def tags_to_dict(tags):

tag_dict = {}
if len(tags) > 0:
tag_dict = {tag.get('Key', '').lstrip().rstrip()
: tag.get('Value', '') for tag in tags}
tag_dict = {tag.get('Key', '').lstrip().rstrip(): tag.get('Value', '') for tag in tags}
return tag_dict


Expand Down
Binary file modified code/ddns-lambda.zip
Binary file not shown.

0 comments on commit 04fa566

Please sign in to comment.