add better route53 logging
Build and Push Container / build-and-push (push) Successful in 28s

This commit is contained in:
2026-08-01 13:33:30 -04:00
parent 99215ec8cf
commit 60c283457b
+9 -2
View File
@@ -16,8 +16,10 @@ except ImportError:
load_dotenv() load_dotenv()
log_level = os.getenv("LOG_LEVEL", "INFO").upper()
logging.basicConfig( logging.basicConfig(
level=logging.INFO, level=log_level,
format="%(asctime)s.%(msecs)03d %(levelname)s %(module)s - %(funcName)s: %(message)s", format="%(asctime)s.%(msecs)03d %(levelname)s %(module)s - %(funcName)s: %(message)s",
datefmt="%Y-%m-%d %H:%M:%S", datefmt="%Y-%m-%d %H:%M:%S",
) )
@@ -45,14 +47,18 @@ def _get_current_record(hosted_zone_id: str, record: str, record_type: str) -> s
if rrset["Name"].rstrip(".") == record_normalized and rrset["Type"] == record_type: if rrset["Name"].rstrip(".") == record_normalized and rrset["Type"] == record_type:
records = rrset.get("ResourceRecords", []) records = rrset.get("ResourceRecords", [])
if records: if records:
return records[0]["Value"].rstrip(".") value = records[0]["Value"].rstrip(".")
logger.debug("Found %s record %s: value='%s' (len=%d)", record_type, record, value, len(value))
return value
except Exception as e: except Exception as e:
logger.warning("Failed to get current %s record for %s: %s", record_type, record, e) logger.warning("Failed to get current %s record for %s: %s", record_type, record, e)
logger.debug("No %s record found for %s", record_type, record)
return None return None
def update_ipv4(hosted_zone_id: str, record: str, public_ipv4: str) -> bool: def update_ipv4(hosted_zone_id: str, record: str, public_ipv4: str) -> bool:
current = _get_current_record(hosted_zone_id, record, "A") current = _get_current_record(hosted_zone_id, record, "A")
logger.debug("IPv4 comparison for %s: current='%s' (len=%d) vs desired='%s' (len=%d)", record, current, len(current or ""), public_ipv4, len(public_ipv4))
if current == public_ipv4: if current == public_ipv4:
logger.info("IPv4 for %s is already %s, no update needed", record, public_ipv4) logger.info("IPv4 for %s is already %s, no update needed", record, public_ipv4)
return False return False
@@ -87,6 +93,7 @@ def update_ipv4(hosted_zone_id: str, record: str, public_ipv4: str) -> bool:
def update_ipv6(hosted_zone_id: str, record: str, public_ipv6: str) -> bool: def update_ipv6(hosted_zone_id: str, record: str, public_ipv6: str) -> bool:
current = _get_current_record(hosted_zone_id, record, "AAAA") current = _get_current_record(hosted_zone_id, record, "AAAA")
logger.debug("IPv6 comparison for %s: current='%s' (len=%d) vs desired='%s' (len=%d)", record, current, len(current or ""), public_ipv6, len(public_ipv6))
if current == public_ipv6: if current == public_ipv6:
logger.info("IPv6 for %s is already %s, no update needed", record, public_ipv6) logger.info("IPv6 for %s is already %s, no update needed", record, public_ipv6)
return False return False