diff --git a/code/ddns-lambda.py b/code/ddns-lambda.py index 8f5042e..07306f6 100755 --- a/code/ddns-lambda.py +++ b/code/ddns-lambda.py @@ -73,7 +73,7 @@ LOGGER = logging.getLogger() account_id = None region = None -VERSION = '1.2.0b37' +VERSION = '1.2.0b38' # Read Env variables DEBUG_LOG_LEVEL = os.environ.get('DebugLogLevel', 'INFO') @@ -761,13 +761,8 @@ def lambda_handler( 'A', private_ip ) - append_msg = 'A record in zone id: ' + \ - str(final_hosted_zone_id) + \ - ' for hosted zone ' + \ - str(final_private_hostname) + '.' + \ - str(final_hosted_zone_name) + \ - ' with value: ' + \ - str(private_ip) + append_msg = f'A record in zone id: {final_hosted_zone_id} for hostname {final_private_hostname} ' + \ + f'zone {final_hosted_zone_name} to value {private_ip}' if create_response == 'success': LOGGER.info("instance: %s, Created %s", instance_id, append_msg + lineno()) @@ -794,13 +789,8 @@ def lambda_handler( 'TXT', heritage_value ) - append_msg = 'TXT record in zone id: ' + \ - str(final_hosted_zone_id) + \ - ' for hosted zone ' + \ - str(final_private_hostname) + '.' + \ - str(final_hosted_zone_name) + \ - ' with value: ' + \ - str(heritage_value) + append_msg = f'TXT record in zone id: {reverse_lookup_zone_id} for hostname {final_private_hostname} ' + \ + f'zone {final_hosted_zone_name} to value {heritage_value)}' if create_response == 'success': LOGGER.info("instance: %s, Created %s", @@ -823,19 +813,13 @@ def lambda_handler( route53, instance_id, reverse_lookup_zone_id, - # reversed_entry, - # reversed_lookup_zone, tag_data['ptr_entry'].hostname, tag_data['ptr_entry'].zonename, 'PTR', create_fqdn(final_private_hostname, final_hosted_zone_name), - # final_private_dns_name ) - append_msg = 'PTR record in zone id: ' + \ - str(reverse_lookup_zone_id) + \ - ' for hosted zone ' + \ - str(reversed_entry) + \ - str(final_private_dns_name) + append_msg = f'PTR record in zone id: {reverse_lookup_zone_id} for hostname {tag_data['ptr_entry'].hostname} ' + \ + f'zone {tag_data['ptr_entry'].zonename} to value {final_private_dns_name)}' if create_response == 'success': LOGGER.info("instance: %s, Created %s", instance_id, append_msg + lineno()) @@ -858,20 +842,13 @@ def lambda_handler( route53, instance_id, reverse_lookup_zone_id, - # reversed_ip_address, - # 'in-addr.arpa', - # reversed_entry, - # reversed_lookup_zone, tag_data['ptr_entry'].hostname, tag_data['ptr_entry'].zonename, 'TXT', heritage_value ) - append_msg = 'TXT reverse record in zone id: ' + \ - str(reverse_lookup_zone_id) + \ - ' for hosted zone ' + \ - str(reversed_entry) + \ - str(heritage_value) + append_msg = f'TXT record in zone id: {reverse_lookup_zone_id} for hostname {tag_data['ptr_entry'].hostname} ' + \ + f'zone {tag_data['ptr_entry'].zonename} to value {heritage_value}' if create_response == 'success': LOGGER.info("instance: %s, Created %s", @@ -3127,9 +3104,6 @@ def create_fqdn(host, zone): :return (str,str): Tuple containing hostname components (may include dot) and domain name for which a PHZ exists. None is returned if not found. """ - hh = parse_hostname_to_components(host) - if hh[1] == '': - hh[1] = zone - fqdn = hh[0] + '.' + hh[1] + fqdn = host.replace(zone, '').rstrip('.') + '.' + zone fqdn += '.' if fqdn[-1] != '.' else '' return fqdn diff --git a/code/ddns-lambda.zip b/code/ddns-lambda.zip index 35391a5..2c93a69 100644 Binary files a/code/ddns-lambda.zip and b/code/ddns-lambda.zip differ