Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2.4.0
uses: actions/checkout@v4.0.0

- name: Run tests
run: go test -race ./...
Expand Down
7 changes: 5 additions & 2 deletions cli/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func ConfigureAddCommand(app *kingpin.Application, a *AwsVault) {
}

func AddCommand(input AddCommandInput, keyring keyring.Keyring, awsConfigFile *vault.ConfigFile) error {
var accessKeyId, secretKey string
var accessKeyId, secretKey, sessionToken string

p, _ := awsConfigFile.ProfileSection(input.ProfileName)
if p.SourceProfile != "" {
Expand All @@ -65,6 +65,9 @@ func AddCommand(input AddCommandInput, keyring keyring.Keyring, awsConfigFile *v
if secretKey = os.Getenv("AWS_SECRET_ACCESS_KEY"); secretKey == "" {
return fmt.Errorf("Missing value for AWS_SECRET_ACCESS_KEY")
}
if sessionToken = os.Getenv("AWS_SESSION_TOKEN"); sessionToken == "" {
return fmt.Errorf("Missing value for AWS_SESSION_TOKEN")
}
} else {
var err error
if accessKeyId, err = prompt.TerminalPrompt("Enter Access Key ID: "); err != nil {
Expand All @@ -75,7 +78,7 @@ func AddCommand(input AddCommandInput, keyring keyring.Keyring, awsConfigFile *v
}
}

creds := aws.Credentials{AccessKeyID: accessKeyId, SecretAccessKey: secretKey}
creds := aws.Credentials{AccessKeyID: accessKeyId, SecretAccessKey: secretKey, SessionToken: sessionToken}

ckr := &vault.CredentialKeyring{Keyring: keyring}
if err := ckr.Set(input.ProfileName, creds); err != nil {
Expand Down