Skip to content

Commit

Permalink
Merge pull request #43 from schwamster/next
Browse files Browse the repository at this point in the history
Merge #41
  • Loading branch information
schwamster committed Apr 9, 2021
2 parents 0cd003b + 91b26a5 commit 221491d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

/**
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 221491d

Please sign in to comment.