From 2948c628a5cb9661e054aaf8098a888ddf214846 Mon Sep 17 00:00:00 2001 From: Gabriel Plassard Date: Mon, 24 Feb 2020 17:05:14 +0100 Subject: [PATCH] Use pagination when there are too many certificates fixes #314 --- index.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/index.ts b/index.ts index 9297286c..cceac0c3 100644 --- a/index.ts +++ b/index.ts @@ -260,13 +260,18 @@ class ServerlessCustomDomain { let certificateArn; // The arn of the choosen certificate let certificateName = this.serverless.service.custom.customDomain.certificateName; // The certificate name - let certData; try { - certData = await this.acm.listCertificates( - { CertificateStatuses: certStatuses }).promise(); + let certificates = []; + let nextToken; + do { + const certData = await this.acm.listCertificates( + { CertificateStatuses: certStatuses, NextToken: nextToken }).promise(); + certificates = certificates.concat(certData.CertificateSummaryList); + nextToken = certData.NextToken; + } while (nextToken); + // The more specific name will be the longest let nameLength = 0; - const certificates = certData.CertificateSummaryList; // Checks if a certificate name is given if (certificateName != null) {