Skip to content

Commit

Permalink
Prioritize Role over environment variables (#161)
Browse files Browse the repository at this point in the history
* Update aws.go

* add also to subscriber
  • Loading branch information
wild-endeavor authored and jprobinson committed Nov 5, 2018
1 parent ca1565f commit 19b29a0
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions pubsub/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,14 @@ func NewPublisher(cfg SNSConfig) (pubsub.Publisher, error) {
var creds *credentials.Credentials
if cfg.AccessKey != "" {
creds = credentials.NewStaticCredentials(cfg.AccessKey, cfg.SecretKey, cfg.SessionToken)
} else {
creds = credentials.NewEnvCredentials()
}

if cfg.RoleARN != "" {
} else if cfg.RoleARN != "" {
var err error
creds, err = requestRoleCredentials(creds, cfg.RoleARN, cfg.MFASerialNumber)
if err != nil {
return p, err
}
} else {
creds = credentials.NewEnvCredentials()
}

sess, err := session.NewSession()
Expand Down Expand Up @@ -204,15 +202,14 @@ func NewSubscriber(cfg SQSConfig) (pubsub.Subscriber, error) {
var creds *credentials.Credentials
if cfg.AccessKey != "" {
creds = credentials.NewStaticCredentials(cfg.AccessKey, cfg.SecretKey, cfg.SessionToken)
} else {
creds = credentials.NewEnvCredentials()
}

if cfg.RoleARN != "" {
} else if cfg.RoleARN != "" {
var err error
creds, err = requestRoleCredentials(creds, cfg.RoleARN, cfg.MFASerialNumber)
if err != nil {
return s, err
}
} else {
creds = credentials.NewEnvCredentials()
}

sess, err := session.NewSession()
Expand Down

0 comments on commit 19b29a0

Please sign in to comment.