diff --git a/code/ddns-lambda.py b/code/ddns-lambda.py index 069122d..064c1b3 100755 --- a/code/ddns-lambda.py +++ b/code/ddns-lambda.py @@ -67,12 +67,13 @@ from botocore.exceptions import ClientError from collections import OrderedDict from pprint import pformat +from dateutil.parser import parse as date_parse # Setting Global Variables LOGGER = logging.getLogger() ACCOUNT = None REGION = None -VERSION = '0.1.15' +VERSION = '0.1.16' # Adjust the logging level [logging.INFO, logging.DEBUG, logging.WARNING, etc] LOGGER.setLevel(logging.DEBUG) @@ -271,13 +272,14 @@ def lambda_handler( try: private_ip = instance['Reservations'][0]['Instances'][0]['PrivateIpAddress'] launch_time = instance['Reservations'][0]['Instances'][0]['LaunchTime'] + launch_time_date = date_parse(str(launch_time)) private_dns_name = instance['Reservations'][0]['Instances'][0]['PrivateDnsName'] private_host_name = private_dns_name.split('.')[0] LOGGER.debug("private ip: %s", str(private_ip) + lineno()) LOGGER.debug("launch time: %s", str(launch_time) + lineno()) LOGGER.debug("launch time timestamp: %s", str( - int(launch_time.timestamp())) + lineno()) + int(launch_time_date.timestamp())) + lineno()) LOGGER.debug("private_dns_name: %s", str(private_dns_name) + lineno()) LOGGER.debug("private_host_name: %s", str(private_host_name) + lineno()) except: @@ -627,7 +629,7 @@ def lambda_handler( 'instance_id': instance_id, }) add_heritage_item_timestamp(heritage, 'create_time', - int(launch_time.timestamp())) + int(launch_time_date.timestamp())) heritage_value = format_heritage(heritage) heritage_value = '"{}"'.format(heritage_value) if len( heritage_value) else heritage_value