diff --git a/code/ddns-lambda.py b/code/ddns-lambda.py index 8d10ab5..a27bdb0 100755 --- a/code/ddns-lambda.py +++ b/code/ddns-lambda.py @@ -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 @@ -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, @@ -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) @@ -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 @@ -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 @@ -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 diff --git a/code/ddns-lambda.zip b/code/ddns-lambda.zip index 40c89d4..6a71131 100644 Binary files a/code/ddns-lambda.zip and b/code/ddns-lambda.zip differ