Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Apr 27, 2023
1 parent 1be8e0a commit 955a38d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions code/ddns-lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
LOGGER = logging.getLogger()
account_id = None
region = None
VERSION = '1.2.0b84'
VERSION = '1.2.0b85'

# Read Env variables
DEBUG_LOG_LEVEL = os.environ.get('DebugLogLevel', 'INFO')
Expand Down Expand Up @@ -733,7 +733,7 @@ def lambda_handler(
cf_zonename = f_zonename
else:
LOGGER.info(
f"4.3 instance: {instance_id}, CNAME no valid hostname {tag_data['option_cname'].hostname} or zone {f_zonename} found, skipping CNAME")
f"4.3 instance: {instance_id}, CNAME no valid hostname {tag_data['option_cname'].hostname} or zone {tag_data['option_cname'].zonename}|{f_zonename} found, skipping CNAME")
cf_hostname = None
cf_zonename = None
if cf_hostname and cf_zonename:
Expand All @@ -756,20 +756,21 @@ def lambda_handler(
f"5.3 instance: {instance_id}, PTR default using current hostname {f_hostname} and current zone {f_zonename}")
p_hostname = f_hostname
p_zonename = f_zonename
p_fqdn = create_fqdn(p_hostname, p_zonename)

# note this will not continue and set a cname

final_private_hostname = f_hostname if len(f_hostname) > 0 else default_hostname
final_hosted_zone_name = f_zonename
# final_private_dns_name = '.'.join([f_hostname, f_zonename])
p_fqdn = create_fqdn(final_private_hostname, final_hosted_zone_name)
final_private_dns_name = p_fqdn
final_private_dns_name = create_fqdn(final_private_hostname, final_hosted_zone_name)
f_fqdn = create_fqdn(final_private_hostname, final_hosted_zone_name)

zone_data_fields = ['name', 'zone_id', 'owner_account', 'is_amazon', 'enabled']
zone_data_tuple = namedtuple('ZoneData', zone_data_fields)

LOGGER.info("instance: %s, final names for A and PTR record host %s zone %s fqdn %s: %s",
instance_id, f_hostname, f_zonename, str(final_private_dns_name), lineno())
LOGGER.info(
f"instance: {instance_id}, final names for A and PTR record host {f_hostname} zone {f_zonename} fqdn {final_private_dns_name} ptr-fqdn {p_fqdn} {lineno()}")

# Get the PHZ ID for the Zone
zone_data_forward = zone_data_tuple(
Expand Down Expand Up @@ -887,14 +888,14 @@ def lambda_handler(
tag_data['ptr_entry'].hostname,
tag_data['ptr_entry'].zonename,
'PTR',
final_private_dns_name,
p_fqdn
)
append_msg = f"PTR record in zone id: {zone_data_reverse.zone_id} owner {zone_data_reverse.owner_account} for hostname {tag_data['ptr_entry'].hostname} " + \
f"zone {tag_data['ptr_entry'].zonename} to value {final_private_dns_name}"
f"zone {tag_data['ptr_entry'].zonename} to value {p_fqdn}"
count[create_response] += 1
if create_response == 'success':
dns_data.append(dns_data_tuple(
zone_data_reverse.zone_id, tag_data['ptr_entry'].hostname, tag_data['ptr_entry'].zonename, 'PTR', final_private_dns_name))
zone_data_reverse.zone_id, tag_data['ptr_entry'].hostname, tag_data['ptr_entry'].zonename, 'PTR', p_fqdn))
LOGGER.info("instance: %s, Created %s",
instance_id, append_msg + lineno())
caller_response.append('Created ' + append_msg)
Expand Down
Binary file modified code/ddns-lambda.zip
Binary file not shown.

0 comments on commit 955a38d

Please sign in to comment.