diff --git a/code/ddns-lambda.py b/code/ddns-lambda.py index 642c93f..f0a0f17 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.0b67' +VERSION = '1.2.0b68' # Read Env variables DEBUG_LOG_LEVEL = os.environ.get('DebugLogLevel', 'INFO') @@ -904,13 +904,16 @@ def lambda_handler( # 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 -# so using existing tag data will not be valid +# so using existing tag data will not be valid. nodelete_dns_data is written back to the ddb if there are entries which did not get removed if state != 'running': heritage_records = {} + o_dns_data = dns_data.copy() + nodelete_dns_data = [] for entry in dns_data: if entry.rr_type == 'TXT' and "heritage=" in entry.rr_value: heritage_records[entry.rr_name] = entry.rr_value + p_delete = True for entry in dns_data: if not (entry.rr_type == 'TXT' and "heritage=" in entry.rr_value): process_response = new_process_delete_records( @@ -918,6 +921,10 @@ def lambda_handler( delete_records = delete_records and process_response['delete_success'] caller_response = caller_response + process_response['msg'] count[f"delete_success.{process_response.get('delete_success')}"] += 1 + p_delete = process_response['delete_success'] + if not p_delete: + nodelete_dns_data.append(entry) + dns_data = nodelete_dns_data # # Process and delete A record and associated TXT record # process_response = process_delete_records( diff --git a/code/ddns-lambda.zip b/code/ddns-lambda.zip index d34aa04..4780c88 100644 Binary files a/code/ddns-lambda.zip and b/code/ddns-lambda.zip differ