Merge pull request #2803 from TimeIncOSS/simplify-aws-creds-check

aws: Simplify ValidateCredentials func
This commit is contained in:
Clint 2015-07-21 09:19:38 -05:00
commit f7ab12cf56
1 changed files with 5 additions and 7 deletions

View File

@ -174,16 +174,14 @@ func (c *Config) ValidateRegion() error {
// Validate credentials early and fail before we do any graph walking
func (c *Config) ValidateCredentials(iamconn *iam.IAM) error {
_, err := iamconn.GetUser(nil)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
if awsErr.Code() == "SignatureDoesNotMatch" {
return fmt.Errorf("Failed authenticating with AWS: please verify credentials")
}
if awsErr, ok := err.(awserr.Error); ok {
if awsErr.Code() == "SignatureDoesNotMatch" {
return fmt.Errorf("Failed authenticating with AWS: please verify credentials")
}
return err
}
return nil
return err
}
// ValidateAccountId returns a context-specific error if the configured account