Skip to content

Commit f2a173f

Browse files
authored
Merge pull request #1577 from snyk/fix/rm-consumer-specific-errmsg
fix: enumlib: remove a scan-specific error message
2 parents 25c259d + b33c42f commit f2a173f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

enumeration/remote/aws/provider.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,13 @@ func (p *AWSTerraformProvider) Version() string {
101101
return p.version
102102
}
103103

104+
var AWSCredentialsNotFoundError = errors.New("Could not find a way to authenticate on AWS!\n" +
105+
"Please refer to AWS documentation: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html")
106+
104107
func (p *AWSTerraformProvider) CheckCredentialsExist() error {
105108
_, err := p.session.Config.Credentials.Get()
106109
if err == credentials.ErrNoValidProvidersFoundInChain {
107-
return errors.New("Could not find a way to authenticate on AWS!\n" +
108-
"Please refer to AWS documentation: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html\n\n" +
109-
"To use a different cloud provider, use --to=\"gcp+tf\" for GCP or --to=\"azure+tf\" for Azure.")
110+
return AWSCredentialsNotFoundError
110111
}
111112
if err != nil {
112113
return err

pkg/cmd/scan.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/snyk/driftctl/build"
1919
"github.com/snyk/driftctl/enumeration/alerter"
2020
"github.com/snyk/driftctl/enumeration/remote"
21+
"github.com/snyk/driftctl/enumeration/remote/aws"
2122
"github.com/snyk/driftctl/enumeration/remote/common"
2223
"github.com/snyk/driftctl/enumeration/terraform"
2324
"github.com/snyk/driftctl/enumeration/terraform/lock"
@@ -293,6 +294,12 @@ func scanRun(opts *pkg.ScanOptions) error {
293294

294295
err := remote.Activate(opts.To, opts.ProviderVersion, alerter, providerLibrary, remoteLibrary, scanProgress, resFactory, opts.ConfigDir)
295296
if err != nil {
297+
if err == aws.AWSCredentialsNotFoundError {
298+
// special case command-line advice, because AWS is the default cloud
299+
// provider, and users may be confused by a cloud-specific error out of
300+
// the box
301+
return fmt.Errorf("%s\n\n%s", err, "To use a different cloud provider, use --to=\"gcp+tf\" for GCP or --to=\"azure+tf\" for Azure.")
302+
}
296303
return err
297304
}
298305

0 commit comments

Comments
 (0)