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

add support for programatically setting custom aws credentials #529

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/awsutil/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type Credentials struct {
SecretAccessKey string
SessionToken string

Credentials *credentials.Credentials

CustomEndpoints config.CustomEndpoints
session *session.Session
}
Expand All @@ -41,6 +43,10 @@ func (c *Credentials) HasProfile() bool {
return strings.TrimSpace(c.Profile) != ""
}

func (c *Credentials) HasAwsCredentials() bool {
return c.Credentials != nil
}

func (c *Credentials) HasKeys() bool {
return strings.TrimSpace(c.AccessKeyID) != "" ||
strings.TrimSpace(c.SecretAccessKey) != "" ||
Expand All @@ -65,6 +71,12 @@ func (c *Credentials) rootSession() (*session.Session, error) {
log.Debugf("creating new root session in %s", region)

switch {
case c.HasAwsCredentials():
opts = session.Options{
Config: aws.Config{
Credentials: c.Credentials,
},
}
case c.HasProfile() && c.HasKeys():
return nil, fmt.Errorf("You have to specify a profile or credentials for at least one region.")

Expand Down