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

clean environment every time #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 4 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,14 @@ func main() {
must(fmt.Errorf("%s not in ~/.aws/roles", role))
}

if os.Getenv("ASSUMED_ROLE") != "" {
// Clear out any previously set AWS_ environment variables so
// they aren't used by this call
cleanEnv()
}
// Clear out any previously set AWS_ environment variables so
// they aren't used by this call
cleanEnv()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think cleanEnv() should actually just get removed. If we don't want aws-sdk-go to use creds from the environment, then we should just swap out the credential chain with an explicit SharedCredentialsProvider. I think it'd look something like:

config := aws.Config{Credentials: &credentials.SharedCredentialsProvider{Filename: "", Profile: ""}}
session := session.New(config)

cleanEnv() is some cruft from when this tool would shell out to the aws cli.


creds, err = assumeRole(roleConfig.Role, roleConfig.MFA, *duration)
must(err)
} else {
if os.Getenv("ASSUMED_ROLE") != "" {
cleanEnv()
}
cleanEnv()
creds, err = assumeProfile(role)
must(err)
}
Expand Down