Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Apr 24, 2023
1 parent 8dc5160 commit 1aa7793
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 36 deletions.
46 changes: 10 additions & 36 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.0b37'
VERSION = '1.2.0b38'

# Read Env variables
DEBUG_LOG_LEVEL = os.environ.get('DebugLogLevel', 'INFO')
Expand Down Expand Up @@ -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())
Expand All @@ -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",
Expand All @@ -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())
Expand All @@ -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",
Expand Down Expand Up @@ -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
Binary file modified code/ddns-lambda.zip
Binary file not shown.

0 comments on commit 1aa7793

Please sign in to comment.