From aa374d03efa803b68d482393251b5168c062ed55 Mon Sep 17 00:00:00 2001 From: rddimon Date: Wed, 22 Nov 2023 19:55:43 +0200 Subject: [PATCH] AT-10890: Fix types https://amplify-education.atlassian.net/browse/AT-10890 --- package-lock.json | 180 +++++++++++++++++++++--------- src/aws/acm-wrapper.ts | 29 +++-- src/aws/api-gateway-v1-wrapper.ts | 30 ++--- src/aws/api-gateway-v2-wrapper.ts | 44 ++++---- src/aws/route53-wrapper.ts | 28 ++--- src/index.ts | 5 +- src/models/apigateway-base.ts | 3 - 7 files changed, 199 insertions(+), 120 deletions(-) diff --git a/package-lock.json b/package-lock.json index ff2be77d..13bbdd88 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2339,17 +2339,89 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.5.tgz", - "integrity": "sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==", + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.4.tgz", + "integrity": "sha512-r1IONyb6Ia+jYR2vvIDhdWdlTGhqbBoFqLTQidzZ4kepUFH15ejXvFHxCVbtl7BOXIudsIubf4E81xeA3h3IXA==", "dev": true, "dependencies": { - "@babel/highlight": "^7.22.5" + "@babel/highlight": "^7.23.4", + "chalk": "^2.4.2" }, "engines": { "node": ">=6.9.0" } }, + "node_modules/@babel/code-frame/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/code-frame/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/@babel/code-frame/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/code-frame/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/compat-data": { "version": "7.22.5", "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.5.tgz", @@ -2390,12 +2462,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.5.tgz", - "integrity": "sha512-+lcUbnTRhd0jOewtFSedLyiPsD5tswKkbgcezOqqWFUVNEwoUTlpPOBmvhG7OXWLR4jMdv0czPGH5XbflnD1EA==", + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.4.tgz", + "integrity": "sha512-esuS49Cga3HcThFNebGhlgsrVLkvhqvYDTzgjfFFlHJcIfLe5jFmRRfCQ1KuBfc4Jrtn3ndLgKWAKjBE+IraYQ==", "dev": true, "dependencies": { - "@babel/types": "^7.22.5", + "@babel/types": "^7.23.4", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -2438,22 +2510,22 @@ } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", - "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-function-name": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", - "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, "dependencies": { - "@babel/template": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" @@ -2515,9 +2587,9 @@ } }, "node_modules/@babel/helper-split-export-declaration": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.5.tgz", - "integrity": "sha512-thqK5QFghPKWLhAV321lxF95yCg2K3Ob5yw+M3VHWfdia0IkPXUtoLH8x/6Fh486QUvzhb8YOWHChTVen2/PoQ==", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, "dependencies": { "@babel/types": "^7.22.5" @@ -2527,18 +2599,18 @@ } }, "node_modules/@babel/helper-string-parser": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", - "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz", + "integrity": "sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", - "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "dev": true, "engines": { "node": ">=6.9.0" @@ -2568,13 +2640,13 @@ } }, "node_modules/@babel/highlight": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.5.tgz", - "integrity": "sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==", + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.23.4.tgz", + "integrity": "sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.22.5", - "chalk": "^2.0.0", + "@babel/helper-validator-identifier": "^7.22.20", + "chalk": "^2.4.2", "js-tokens": "^4.0.0" }, "engines": { @@ -2653,9 +2725,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.5.tgz", - "integrity": "sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q==", + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.4.tgz", + "integrity": "sha512-vf3Xna6UEprW+7t6EtOmFpHNAuxw3xqPZghy+brsnusscJRW5BMUzzHZc5ICjULee81WeUV2jjakG09MDglJXQ==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -2665,33 +2737,33 @@ } }, "node_modules/@babel/template": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", - "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.5.tgz", - "integrity": "sha512-7DuIjPgERaNo6r+PZwItpjCZEa5vyw4eJGufeLxrPdBXBoLcCJCIasvK6pK/9DVNrLZTLFhUGqaC6X/PA007TQ==", + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.4.tgz", + "integrity": "sha512-IYM8wSUwunWTB6tFC2dkKZhxbIjHoWemdK+3f8/wq8aKhbUscxD5MX72ubd90fxvFknaLPeGw5ycU84V1obHJg==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/generator": "^7.22.5", - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-function-name": "^7.22.5", + "@babel/code-frame": "^7.23.4", + "@babel/generator": "^7.23.4", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", "@babel/helper-hoist-variables": "^7.22.5", - "@babel/helper-split-export-declaration": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.4", + "@babel/types": "^7.23.4", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -2700,13 +2772,13 @@ } }, "node_modules/@babel/types": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.5.tgz", - "integrity": "sha512-zo3MIHGOkPOfoRXitsgHLjEXmlDaD/5KU1Uzuc9GNiZPhSqVxVRtxuPaSBZDsYZ9qV88AjtMtWW7ww98loJ9KA==", + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.4.tgz", + "integrity": "sha512-7uIFwVYpoplT5jp/kVv6EF93VaJ8H+Yn5IczYiaAi98ajzjfoZfslet/e0sLh+wVBjb2qqIut1b0S26VSafsSQ==", "dev": true, "dependencies": { - "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-string-parser": "^7.23.4", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": { diff --git a/src/aws/acm-wrapper.ts b/src/aws/acm-wrapper.ts index dcfc436c..c7b8400e 100644 --- a/src/aws/acm-wrapper.ts +++ b/src/aws/acm-wrapper.ts @@ -1,15 +1,20 @@ import { - ACMClient, - CertificateSummary, - ListCertificatesCommand, - ListCertificatesCommandInput, - ListCertificatesCommandOutput + CertificateStatus, + ACMClient, + CertificateSummary, + ListCertificatesCommand, + ListCertificatesCommandInput, + ListCertificatesCommandOutput } from "@aws-sdk/client-acm"; import Globals from "../globals"; import DomainConfig = require("../models/domain-config"); -import { getAWSPagedResults } from "../utils"; +import {getAWSPagedResults} from "../utils"; -const certStatuses = ["PENDING_VALIDATION", "ISSUED", "INACTIVE"]; +const certStatuses = [ + CertificateStatus.PENDING_VALIDATION, + CertificateStatus.ISSUED, + CertificateStatus.INACTIVE +]; class ACMWrapper { public acm: ACMClient; @@ -30,11 +35,11 @@ class ACMWrapper { try { const certificates = await getAWSPagedResults( - this.acm, - "CertificateSummaryList", - "NextToken", - "NextToken", - new ListCertificatesCommand({ CertificateStatuses: certStatuses }) + this.acm, + "CertificateSummaryList", + "NextToken", + "NextToken", + new ListCertificatesCommand({CertificateStatuses: certStatuses}) ); // enhancement idea: weight the choice of cert so longer expires // and RenewalEligibility = ELIGIBLE is more preferable diff --git a/src/aws/api-gateway-v1-wrapper.ts b/src/aws/api-gateway-v1-wrapper.ts index 0ddd75cc..dfe3549c 100644 --- a/src/aws/api-gateway-v1-wrapper.ts +++ b/src/aws/api-gateway-v1-wrapper.ts @@ -5,26 +5,28 @@ import DomainConfig = require("../models/domain-config"); import DomainInfo = require("../models/domain-info"); import Globals from "../globals"; import { - APIGatewayClient, - BasePathMapping, - CreateBasePathMappingCommand, - CreateDomainNameCommand, - CreateDomainNameCommandOutput, - DeleteBasePathMappingCommand, - DeleteDomainNameCommand, - GetBasePathMappingsCommand, - GetBasePathMappingsCommandInput, - GetBasePathMappingsCommandOutput, - GetDomainNameCommand, - GetDomainNameCommandOutput, - UpdateBasePathMappingCommand + APIGatewayClient, + BasePathMapping, + CreateBasePathMappingCommand, + CreateDomainNameCommand, + CreateDomainNameCommandOutput, + DeleteBasePathMappingCommand, + DeleteDomainNameCommand, + GetBasePathMappingsCommand, + GetBasePathMappingsCommandInput, + GetBasePathMappingsCommandOutput, + GetDomainNameCommand, + GetDomainNameCommandOutput, + UpdateBasePathMappingCommand } from "@aws-sdk/client-api-gateway"; import ApiGatewayMap = require("../models/api-gateway-map"); import APIGatewayBase = require("../models/apigateway-base"); import Logging from "../logging"; -import { getAWSPagedResults } from "../utils"; +import {getAWSPagedResults} from "../utils"; class APIGatewayV1Wrapper extends APIGatewayBase { + public readonly apiGateway: APIGatewayClient; + constructor(credentials?: any) { super(); this.apiGateway = new APIGatewayClient({ diff --git a/src/aws/api-gateway-v2-wrapper.ts b/src/aws/api-gateway-v2-wrapper.ts index 29b53fb0..18bcba4c 100644 --- a/src/aws/api-gateway-v2-wrapper.ts +++ b/src/aws/api-gateway-v2-wrapper.ts @@ -7,24 +7,26 @@ import Globals from "../globals"; import ApiGatewayMap = require("../models/api-gateway-map"); import APIGatewayBase = require("../models/apigateway-base"); import { - ApiGatewayV2Client, - ApiMapping, - CreateApiMappingCommand, - CreateDomainNameCommand, - CreateDomainNameCommandOutput, - DeleteApiMappingCommand, - DeleteDomainNameCommand, - GetApiMappingsCommand, - GetApiMappingsCommandInput, - GetApiMappingsCommandOutput, - GetDomainNameCommand, - GetDomainNameCommandOutput, - UpdateApiMappingCommand + ApiGatewayV2Client, + ApiMapping, + CreateApiMappingCommand, + CreateDomainNameCommand, + CreateDomainNameCommandOutput, + DeleteApiMappingCommand, + DeleteDomainNameCommand, + GetApiMappingsCommand, + GetApiMappingsCommandInput, + GetApiMappingsCommandOutput, + GetDomainNameCommand, + GetDomainNameCommandOutput, + UpdateApiMappingCommand } from "@aws-sdk/client-apigatewayv2"; import Logging from "../logging"; -import { getAWSPagedResults } from "../utils"; +import {getAWSPagedResults} from "../utils"; class APIGatewayV2Wrapper extends APIGatewayBase { + public readonly apiGateway: ApiGatewayV2Client; + constructor(credentials?: any) { super(); this.apiGateway = new ApiGatewayV2Client({ @@ -157,13 +159,13 @@ class APIGatewayV2Wrapper extends APIGatewayBase { public async getBasePathMappings(domain: DomainConfig): Promise { try { const items = await getAWSPagedResults( - this.apiGateway, - "Items", - "NextToken", - "NextToken", - new GetApiMappingsCommand({ - DomainName: domain.givenDomainName - }) + this.apiGateway, + "Items", + "NextToken", + "NextToken", + new GetApiMappingsCommand({ + DomainName: domain.givenDomainName + }) ); return items.map( (item) => new ApiGatewayMap(item.ApiId, item.ApiMappingKey, item.Stage, item.ApiMappingId) diff --git a/src/aws/route53-wrapper.ts b/src/aws/route53-wrapper.ts index 125017a7..3a8f01ea 100644 --- a/src/aws/route53-wrapper.ts +++ b/src/aws/route53-wrapper.ts @@ -2,14 +2,14 @@ import Globals from "../globals"; import DomainConfig = require("../models/domain-config"); import Logging from "../logging"; import { - ChangeResourceRecordSetsCommand, - HostedZone, - ListHostedZonesCommand, - ListHostedZonesCommandInput, - ListHostedZonesCommandOutput, - Route53Client + ChangeResourceRecordSetsCommand, + HostedZone, + ListHostedZonesCommand, + ListHostedZonesCommandInput, + ListHostedZonesCommandOutput, + Route53Client, RRType, ChangeAction } from "@aws-sdk/client-route-53"; -import { getAWSPagedResults } from "../utils"; +import {getAWSPagedResults} from "../utils"; class Route53Wrapper { public route53: Route53Client; @@ -50,11 +50,11 @@ class Route53Wrapper { let hostedZones = []; try { hostedZones = await getAWSPagedResults( - this.route53, - "HostedZones", - "Marker", - "NextMarker", - new ListHostedZonesCommand({}) + this.route53, + "HostedZones", + "Marker", + "NextMarker", + new ListHostedZonesCommand({}) ); } catch (err) { throw new Error(`Unable to list hosted zones in Route53.\n${err.message}`); @@ -83,7 +83,7 @@ class Route53Wrapper { * @param action: String descriptor of change to be made. Valid actions are ['UPSERT', 'DELETE'] * @param domain: DomainInfo object containing info about custom domain */ - public async changeResourceRecordSet(action: string, domain: DomainConfig): Promise { + public async changeResourceRecordSet(action: ChangeAction, domain: DomainConfig): Promise { if (domain.createRoute53Record === false) { Logging.logInfo(`Skipping ${action === "DELETE" ? "removal" : "creation"} of Route53 record.`); return; @@ -124,7 +124,7 @@ class Route53Wrapper { hostedZoneIds = [route53HostedZoneId]; } - const recordsToCreate = domain.createRoute53IPv6Record ? ["A", "AAAA"] : ["A"]; + const recordsToCreate = domain.createRoute53IPv6Record ? [RRType.AAAA] : [RRType.A]; for (const hostedZoneId of hostedZoneIds) { const changes = recordsToCreate.map((Type) => ({ Action: action, diff --git a/src/index.ts b/src/index.ts index 2d81cb75..7ea78056 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,6 +14,7 @@ import APIGatewayBase = require("./models/apigateway-base"); import Logging from "./logging"; import {loadConfig} from "@aws-sdk/node-config-provider"; import {NODE_REGION_CONFIG_FILE_OPTIONS, NODE_REGION_CONFIG_OPTIONS} from "@aws-sdk/config-resolver"; +import {ChangeAction} from "@aws-sdk/client-route-53"; class ServerlessCustomDomain { @@ -271,7 +272,7 @@ class ServerlessCustomDomain { Logging.logInfo(`Custom domain '${domain.givenDomainName}' already exists.`); } Logging.logInfo(`Creating/updating route53 record for '${domain.givenDomainName}'.`); - await route53.changeResourceRecordSet("UPSERT", domain); + await route53.changeResourceRecordSet(ChangeAction.UPSERT, domain); } catch (err) { throw new Error(`Unable to create domain '${domain.givenDomainName}':\n${err.message}`); } finally { @@ -303,7 +304,7 @@ class ServerlessCustomDomain { try { if (domain.domainInfo) { await apiGateway.deleteCustomDomain(domain); - await route53.changeResourceRecordSet("DELETE", domain); + await route53.changeResourceRecordSet(ChangeAction.DELETE, domain); domain.domainInfo = null; Logging.logInfo(`Custom domain ${domain.givenDomainName} was deleted.`); } else { diff --git a/src/models/apigateway-base.ts b/src/models/apigateway-base.ts index 80af7a77..a12089a9 100644 --- a/src/models/apigateway-base.ts +++ b/src/models/apigateway-base.ts @@ -1,11 +1,8 @@ import DomainInfo = require("./domain-info"); import ApiGatewayMap = require("./api-gateway-map"); import DomainConfig = require("./domain-config"); -import {Client} from "@aws-sdk/smithy-client"; abstract class APIGatewayBase { - public apiGateway: Client; - abstract createCustomDomain(domain: DomainConfig): Promise; abstract getCustomDomain(domain: DomainConfig): Promise;