diff --git a/code/ddns-lambda.py b/code/ddns-lambda.py index f0a0f17..a4d2ffa 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.0b68' +VERSION = '1.2.0b69' # Read Env variables DEBUG_LOG_LEVEL = os.environ.get('DebugLogLevel', 'INFO') @@ -979,38 +979,38 @@ def lambda_handler( # create CNAME record in private zone if state == 'running': try: - # LOGGER.debug("cname_host_name:" - # " %s", str(cname_host_name) + lineno()) - # LOGGER.debug("cname_domain_suffix:" - # " %s", str(cname_domain_suffix) + lineno()) - # LOGGER.debug("cname_domain_suffix_id:" - # " %s", str(cname_domain_suffix_id) + lineno()) - # - create_response = create_resource_record( - route53, - instance_id, - # cname_domain_suffix_id, - # cname_host_name, - # cname_domain_suffix, - cf_zonename_id, - cf_hostname, - cf_zonename, - 'CNAME', - final_private_dns_name, - ) - append_msg = f"CNAME record in zone id: {cf_zonename_id} owner {phz_collection_by_vpc[cf_zonename_id]['owner_account']} " + \ - f"hostname {cf_hostname} in zone {cf_zonename} with value {final_private_dns_name}" + if not flags['nocname']: + LOGGER.debug(f"cname_host_name: {cf_hostname} {lineno()}") + LOGGER.debug(f"cname_domain_suffix: {cf_zonename} {lineno()}") + LOGGER.debug(f"cname_domain_suffix_id: {cf_zonename_id} {lineno()}") + LOGGER.debug(f"cname_target: {final_private_dns_name} {lineno()}") - if create_response == 'success': - dns_data.append(dns_data_tuple( - cf_zonename_id, cf_hostname, cf_zonename, 'CNAME', cf_fqdn)) - LOGGER.info( - f"instance: {instance_id}, Created {append_msg} {lineno()}") - caller_response.append('Created ' + append_msg) - else: - caller_response.append(create_response) - caller_response.append('Failed to create ' + append_msg) - LOGGER.error('Failed to create CNAME record: %s', create_response) + create_response = create_resource_record( + route53, + instance_id, + # cname_domain_suffix_id, + # cname_host_name, + # cname_domain_suffix, + cf_zonename_id, + cf_hostname, + cf_zonename, + 'CNAME', + final_private_dns_name + ) + append_msg = f"CNAME record in zone id: {cf_zonename_id} owner {phz_collection_by_vpc[cf_zonename_id]['owner_account']} " + \ + f"hostname {cf_hostname} in zone {cf_zonename} with value {final_private_dns_name}" + + if create_response == 'success': + dns_data.append(dns_data_tuple( + cf_zonename_id, cf_hostname, cf_zonename, 'CNAME', cf_fqdn)) + LOGGER.info( + f"instance: {instance_id}, Created {append_msg} {lineno()}") + caller_response.append('Created ' + append_msg) + else: + caller_response.append(create_response) + caller_response.append('Failed to create ' + append_msg) + LOGGER.error('Failed to create CNAME record: %s', + create_response) except BaseException as err: LOGGER.error("instance: %s, unexpected error. %s\n", instance_id, str(err) + lineno()) diff --git a/code/ddns-lambda.zip b/code/ddns-lambda.zip index 4780c88..41439d4 100644 Binary files a/code/ddns-lambda.zip and b/code/ddns-lambda.zip differ