Skip to content

Commit 19aa9a2

Browse files
committed
fixed error handling for imds creation
1 parent e802f44 commit 19aa9a2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cmd/aws-iam-authenticator/verify.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ var verifyCmd = &cobra.Command{
8888
func getInstanceRegion(ctx context.Context) string {
8989
cfg, err := config.LoadDefaultConfig(ctx)
9090
if err != nil {
91-
fmt.Printf("[Warn] Unable to create metadata client, err: %v", err)
92-
return ""
91+
fmt.Fprintf(os.Stderr, "[Warn] Unable to create config for metadata client, err: %v", err)
92+
panic(err)
9393
}
9494

9595
imdsClient := imds.NewFromConfig(cfg)
9696
getRegionOutput, err := imdsClient.GetRegion(ctx, &imds.GetRegionInput{})
9797
if err != nil {
98-
fmt.Printf("[Warn] Region not found in instance metadata, err: %v\n", err)
98+
fmt.Fprintf(os.Stderr, "[Warn] Region not found in instance metadata, err: %v\n", err)
9999
return ""
100100
}
101101

0 commit comments

Comments
 (0)