@@ -54,7 +54,7 @@ func ConfigureLoginCommand(app *kingpin.Application, a *AwsVault) {
54
54
Short ('s' ).
55
55
BoolVar (& input .UseStdout )
56
56
57
- cmd .Arg ("profile" , "Name of the profile" ).
57
+ cmd .Arg ("profile" , "Name of the profile. If none given, credentials will be sourced from env vars " ).
58
58
HintAction (a .MustGetProfileNames ).
59
59
StringVar (& input .ProfileName )
60
60
@@ -114,13 +114,10 @@ func LoginCommand(input LoginCommandInput, f *vault.ConfigFile, keyring keyring.
114
114
if err != nil {
115
115
return fmt .Errorf ("Failed to get credentials: %w" , err )
116
116
}
117
- if creds .SessionToken == "" {
118
- // When sourcing credentials from the environment, it's possible a session token wasn't set
119
- // Generating a sign-in link requires temporary credentials, so we return an error
120
- // NOTE: We deliberately chose to have this logic here rather than in 'EnvironmentVariablesCredentialsProvider'
121
- // to make it possible to reuse it for other commands than `aws-vault login` in the future
122
- return fmt .Errorf ("failed to retrieve a session token. Cannot generate a login URL without it" )
117
+ if creds .AccessKeyID == "" && input .ProfileName == "" {
118
+ return fmt .Errorf ("argument 'profile' not provided, nor any AWS env vars found. Try --help" )
123
119
}
120
+
124
121
jsonBytes , err := json .Marshal (map [string ]string {
125
122
"sessionId" : creds .AccessKeyID ,
126
123
"sessionKey" : creds .SecretAccessKey ,
0 commit comments