diff --git a/index.js b/index.js index 28f91c9..8707473 100644 --- a/index.js +++ b/index.js @@ -130,8 +130,15 @@ class CreateCertificatePlugin { .then(() => this.serverless.cli.log('serverless-certificate-creator: disabled.')); } - listCertificates() { - return this.acm.listCertificates({}).promise(); + listCertificates(NextToken) { + return this.acm.listCertificates({ NextToken }).promise() + .then(data => { + if (data.NextToken) { + return this.listCertificates(data.NextToken) + .then(moreData => [...moreData, ...data.CertificateSummaryList]); + } + return Promise.resolve(data.CertificateSummaryList) + }) } /** @@ -194,7 +201,7 @@ class CreateCertificatePlugin { getExistingCertificate() { return this.listCertificates().then(data => { - let existingCerts = data.CertificateSummaryList.filter(cert => cert.DomainName === this.domain); + let existingCerts = data.filter(cert => cert.DomainName === this.domain); if (existingCerts.length > 0) { return existingCerts[0]; } @@ -523,8 +530,8 @@ class CreateCertificatePlugin { } return this.listCertificates() - .then(({ CertificateSummaryList }) => { - let cert = CertificateSummaryList.filter(({ DomainName }) => DomainName == domainName)[0]; + .then(certificates => { + let cert = certificates.filter(({ DomainName }) => DomainName == domainName)[0]; if (cert && cert[property]) { return cert[property]; } else { diff --git a/package.json b/package.json index faba1cf..0f12725 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "serverless-certificate-creator", - "version": "1.5.2", + "version": "1.5.3", "description": "creates a certificate that can be used for custom domains for your api gateway", "main": "index.js", "scripts": {