Skip to content

Commit

Permalink
🐛 trouble shoot (nil pointer error)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghdwlsgur committed Sep 28, 2022
1 parent 442dd4e commit bec3668
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cmd/mfa.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ var (
device := viper.GetString("mfa-device")

if device == "" {
/* AWS CLI Command Reference (https://docs.aws.amazon.com/cli/latest/reference/sts/get-caller-identity.html)
* Example========================================================
aws sts get-caller-identity
=================================================================*/
identity, err := client.GetCallerIdentity(ctx, &sts.GetCallerIdentityInput{})
if err != nil {
panicRed(err)
Expand Down
3 changes: 1 addition & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func setTempConfig(awsRegion string, subcmd *cobra.Command) (string, aws.Config)
temporaryCredentials.Expired() ||
temporaryCredentials.AccessKeyID == "" ||
temporaryCredentials.SecretAccessKey == "" ||
(subcmd.Use == "mfa" && temporaryCredentials.SessionToken != ""))
temporaryCredentials.SessionToken == "")
}

var temporaryCredentialsInvalid = func(temporaryCredentials aws.Credentials) bool {
Expand All @@ -187,7 +187,6 @@ func setTempConfig(awsRegion string, subcmd *cobra.Command) (string, aws.Config)
if err != nil {
panicRed(internal.WrapError(err))
}

temporaryCredentials, err = temporaryConfig.Credentials.Retrieve(context.Background())
if temporaryCredentialsError(temporaryCredentials, err, subcmd) {
panicRed(internal.WrapError(fmt.Errorf("[err] invalid global environments %s", err.Error())))
Expand Down

0 comments on commit bec3668

Please sign in to comment.