'DNS lookup for RDS times out
I have an RDS instance my_instance and a lambda. Both sit on the same VPC.
The RDS has a SC my-security-group-rds and lambda another security group my-security-group-lambda.
my-security-group-lambda has outbound rule without constraints. All protocols with IP 0.0.0.0/0.
my-security-group-rds has an inbound rule that allows any access from my-security-group-lambda.
Inside the lambda I want to perform DNS resolution of the hostname:
def dns_lookup(domainname,record_type,*dnsserver):
"""
Get dns lookup results
:param domain:
:return: list of dns lookup results
"""
try:
lookup_result_list = []
myResolver = dns.resolver.Resolver()
if not dnsserver:
lookupAnswer = myResolver.query(domainname, record_type)
else:
myResolver.nameservers = dnsserver[0]
lookupAnswer = myResolver.query(domainname,record_type)
for answer in lookupAnswer:
lookup_result_list.append(str(answer))
return lookup_result_list
except Exception as err:
logger.exception("Not able to lookup DNS:{}".format(err))
raise
I first perform the dns_lookup on the rds regional server, which works out nicely.
listOfAuthoritiveNames = dns_lookup("eu-west-1.rds.amazonaws.com", "NS")
Then I try to perform dns lookup on my instance:
dns_lookup("my-database.dfafda.eu-west-1.rds.amazonaws.com", "A", listOfAuthoritiveNames)
This gives a timeout. If I use a wrong hostname for the database it says that there is no record, so it would seem that it has access to the nameservers.
Any idea what might be missing?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
