@@ -222,6 +222,7 @@ def create_dns_record(self, record: DNSRecord) -> bool:
222222 """
223223 Create a DNS record.
224224 Injects Weighted Routing if ROUTE53_INITIAL_WEIGHT env var is numeric.
225+ **SKIPS automatic injection for TXT records.**
225226 """
226227 hosted_zone_id = self ._ensure_hosted_zone_id (record .name )
227228 if not hosted_zone_id :
@@ -258,9 +259,12 @@ def create_dns_record(self, record: DNSRecord) -> bool:
258259 weight_to_set = record .data ["weight" ]
259260 else :
260261 # Check Env Var
261- env_weight = os .getenv ("ROUTE53_INITIAL_WEIGHT" )
262- if env_weight is not None and env_weight .isdigit ():
263- weight_to_set = int (env_weight )
262+ # IMPORTANT: Do NOT apply automatic weighting to TXT records
263+ # TXT is used for Certbot challenges/SPF and should not be weighted unless explicitly requested
264+ if record .type != RecordType .TXT :
265+ env_weight = os .getenv ("ROUTE53_INITIAL_WEIGHT" )
266+ if env_weight is not None and env_weight .isdigit ():
267+ weight_to_set = int (env_weight )
264268
265269 # 2. Determine Identifier (Required if Weight is set)
266270 set_identifier = None
@@ -361,12 +365,6 @@ def delete_dns_record(self, record_id: str, domain: str) -> bool:
361365 if record_set .get ("SetIdentifier" ) != set_identifier :
362366 id_match = False
363367
364- # If we have a set_identifier in the record but none in record_id,
365- # we must be careful. However, standard deletion usually implies
366- # non-weighted. If the user passes a simple ID for a weighted record,
367- # this logic might need to be stricter, but for now strict match on
368- # requested ID is safest.
369-
370368 if name_match and type_match and id_match :
371369 record_set_to_delete = record_set
372370 break
0 commit comments