Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail silently when account validation fails while from instance profile #3001

Merged
merged 2 commits into from
Sep 8, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion builtin/providers/aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,18 @@ func (c *Config) ValidateAccountId(iamconn *iam.IAM) error {
log.Printf("[INFO] Validating account ID")

out, err := iamconn.GetUser(nil)

if err != nil {
return fmt.Errorf("Failed getting account ID from IAM: %s", err)
awsErr, _ := err.(awserr.Error)
if awsErr.Code() == "ValidationError" {
log.Printf("[WARN] ValidationError with iam.GetUser, assuming its an IAM profile")
// User may be an IAM instance profile, so fail silently.
// If it is an IAM instance profile
// validating account might be superfluous
} else {
return fmt.Errorf("Failed getting account ID from IAM: %s", err)
// return error if the account id is explicitly not authorised
}
}

account_id := strings.Split(*out.User.ARN, ":")[4]
Expand Down