Skip to content

Commit fe0ed82

Browse files
authored
update alb ip monitor dns lookup check (#1076)
1 parent 696adb8 commit fe0ed82

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/deployments/runtime/src/alb-to-alb-target/alb-ip-monitor.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,15 @@ const dnslookup = async (host: string): Promise<string[]> => {
9090
dns.lookup(host, { all: true, family: 4 }, (err, addresses) => {
9191
if (err) {
9292
reject(err);
93+
} else {
94+
resolve(
95+
addresses
96+
.map(item => {
97+
return item.address;
98+
})
99+
.sort(),
100+
);
93101
}
94-
resolve(
95-
addresses
96-
.map(item => {
97-
return item.address;
98-
})
99-
.sort(),
100-
);
101102
});
102103
});
103104
};
@@ -127,7 +128,12 @@ export const handler = async (_event: any, _context: any) => {
127128
for (const targetGroupRecord of targetGroupRecords) {
128129
try {
129130
// Get Hostname Lookup
130-
targetGroupRecord.dnsLookupIps = (await dnslookup(targetGroupRecord.targetAlbDnsName)) ?? [];
131+
targetGroupRecord.dnsLookupIps = [];
132+
try {
133+
targetGroupRecord.dnsLookupIps = await dnslookup(targetGroupRecord.targetAlbDnsName);
134+
} catch (err) {
135+
console.log(err);
136+
}
131137
// Get Ip Addresses to add to current IP List
132138
targetGroupRecord.ipAddList =
133139
targetGroupRecord.dnsLookupIps?.filter(ip => {

0 commit comments

Comments
 (0)