Skip to content

Commit f35b5a4

Browse files
committed
filter DNS answer to only include A records
1 parent 1dba4f3 commit f35b5a4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

localstack-core/localstack/aws/connect.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,11 @@ def resolve_dns_from_upstream(hostname: str) -> str:
660660
if len(response.answer) == 0:
661661
raise ValueError(f"No DNS response found for hostname '{hostname}'")
662662

663-
ip_addresses = list(response.answer[0].items.keys())
663+
ip_addresses = []
664+
for answer in response.answer:
665+
if answer.match(dns.rdataclass.IN, dns.rdatatype.A, dns.rdatatype.TYPE0):
666+
ip_addresses.extend(answer.items.keys())
667+
664668
return choice(ip_addresses).address
665669

666670

0 commit comments

Comments
 (0)