diff --git a/aws/acm.go b/aws/acm.go index 309b41a..a6018e4 100644 --- a/aws/acm.go +++ b/aws/acm.go @@ -44,16 +44,18 @@ func getACMCertificateSummaries(api acmiface.ACMAPI, filterTag string) ([]*acm.C } acmSummaries := make([]*acm.CertificateSummary, 0) - err := api.ListCertificatesPages(params, func(page *acm.ListCertificatesOutput, lastPage bool) bool { + if err := api.ListCertificatesPages(params, func(page *acm.ListCertificatesOutput, lastPage bool) bool { acmSummaries = append(acmSummaries, page.CertificateSummaryList...) return true - }) + }); err != nil { + return nil, err + } if tag := strings.Split(filterTag, "="); filterTag != "=" && len(tag) == 2 { return filterCertificatesByTag(api, acmSummaries, tag[0], tag[1]) } - return acmSummaries, err + return acmSummaries, nil } func filterCertificatesByTag(api acmiface.ACMAPI, allSummaries []*acm.CertificateSummary, key, value string) ([]*acm.CertificateSummary, error) { diff --git a/aws/acm_test.go b/aws/acm_test.go index 14d96d4..ea5ff81 100644 --- a/aws/acm_test.go +++ b/aws/acm_test.go @@ -1,6 +1,7 @@ package aws import ( + "fmt" "testing" "github.com/aws/aws-sdk-go/aws" @@ -142,6 +143,18 @@ func TestACM(t *testing.T) { DomainNames: []string{"foobar.de"}, }, }, + { + msg: "Fail on ListCertificatesPages error", + api: fake.NewACMClient( + acm.ListCertificatesOutput{}, nil, nil, + ).WithListCertificatesPages(func(input *acm.ListCertificatesInput, fn func(p *acm.ListCertificatesOutput, lastPage bool) (shouldContinue bool)) error { + return fmt.Errorf("ListCertificatesPages error") + }), + filterTag: "production=true", + expect: acmExpect{ + Error: "ListCertificatesPages error", + }, + }, } { t.Run(ti.msg, func(t *testing.T) { provider := newACMCertProvider(ti.api, ti.filterTag)