From bec366841cb7d93c3a07e02ec221624dd54e3bcb Mon Sep 17 00:00:00 2001 From: HongJinHyeok Date: Wed, 28 Sep 2022 13:09:49 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20trouble=20shoot=20(nil=20pointer?= =?UTF-8?q?=20error)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/mfa.go | 4 ++++ cmd/root.go | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/mfa.go b/cmd/mfa.go index 18c5c4a..df4be49 100644 --- a/cmd/mfa.go +++ b/cmd/mfa.go @@ -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) diff --git a/cmd/root.go b/cmd/root.go index 94617c6..450591f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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 { @@ -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())))