From 886d5236130f771c109ff17fc26739e0c2deb56b Mon Sep 17 00:00:00 2001 From: Wanxian Yang Date: Wed, 24 Nov 2021 10:21:17 -0800 Subject: [PATCH] addr fb: fix type; check if the result from listresourcerecordset is exactly the alias (it could be a record >= alias otherwise) --- cf-custom-resources/lib/nlb-cert-validator-updater.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cf-custom-resources/lib/nlb-cert-validator-updater.js b/cf-custom-resources/lib/nlb-cert-validator-updater.js index 80172a26bde..2af5455b819 100644 --- a/cf-custom-resources/lib/nlb-cert-validator-updater.js +++ b/cf-custom-resources/lib/nlb-cert-validator-updater.js @@ -85,7 +85,7 @@ const rootHostedZoneIDContext = () => { }; } -let hostecZoneID = { +let hostedZoneID = { app: appHostedZoneIDContext(), root: rootHostedZoneIDContext(), } @@ -239,11 +239,13 @@ async function validateAliases(aliases, loadBalancerDNS) { if (!recordSet || recordSet.length === 0) { return; } + if (recordSet[0].Name !== alias) { + return; + } let aliasTarget = recordSet[0].AliasTarget; if (aliasTarget && aliasTarget.DNSName === `${loadBalancerDNS}.`) { return; // The record is an alias record and is in use by myself, hence valid. } - if (aliasTarget) { throw new Error(`Alias ${alias} is already in use by ${aliasTarget.DNSName}. This could be another load balancer of a different service.`); } @@ -432,14 +434,14 @@ async function domainResources (alias) { return { domain: domainTypes.AppDomainZone.domain, route53Client: clients.app.route53(), - hostedZoneID: await hostecZoneID.app(), + hostedZoneID: await hostedZoneID.app(), }; } if (domainTypes.RootDomainZone.regex.test(alias)) { return { domain: domainTypes.RootDomainZone.domain, route53Client: clients.root.route53(), - hostedZoneID: await hostecZoneID.root(), + hostedZoneID: await hostedZoneID.root(), }; } throw new Error(`unrecognized domain type for ${alias}`);