Skip to content

Commit

Permalink
Do no use plugin logger.
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-catio committed Oct 2, 2024
1 parent 59b6261 commit 7ba2b77
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ func main() {
printCurrentCallerIdentity(ctx)

if running, err := checkIfPluginRunning("aws.plugin"); err != nil {
plugin.Logger(ctx).Error("Error checking if plugin is running:", err)
fmt.Println("Error checking if plugin is running:", err)
} else if running {
plugin.Logger(ctx).Info("Plugin is already running")
fmt.Println("Plugin is already running")
return
}

Expand All @@ -33,17 +33,17 @@ func printCurrentCallerIdentity(ctx context.Context) {
// use sts client to get caller identity
cfg, err := config.LoadDefaultConfig(ctx)
if err != nil {
plugin.Logger(ctx).Error("Failed to load AWS configuration: %v", err)
fmt.Println("Failed to load AWS configuration:", err)
return
}

// Create an STS client from just the config
svc := sts.NewFromConfig(cfg)
identity, err := svc.GetCallerIdentity(context.TODO(), &sts.GetCallerIdentityInput{})
if err != nil {
plugin.Logger(ctx).Error("Failed to get caller identity:", err)
fmt.Println("Failed to get caller identity:", err)
}
plugin.Logger(ctx).Info("Caller Identity:", *identity.Account, *identity.Arn, *identity.UserId)
fmt.Println("Caller Identity:", *identity.Account, *identity.Arn, *identity.UserId)
}

func checkIfPluginRunning(pluginName string) (bool, error) {
Expand Down

0 comments on commit 7ba2b77

Please sign in to comment.