Skip to content

Commit

Permalink
Show bot instance ID in tbot log output (#44578)
Browse files Browse the repository at this point in the history
This tweaks the "fetched new bot identity" message to show the bot
name and instance ID as embedded in the bot's certificate.

Example:

```
2024-07-23T15:51:20-06:00 INFO [TBOT:IDEN] Fetched new bot identity identity:tpm-test, id=5a2865d3-d3dc-4eaa-853c-5377a1fe83f6 | valid: after=2024-07-23T21:50:20Z, before=2024-07-23T21:56:19Z, duration=5m59s | kind=tls, renewable=false, disallow-reissue=false, roles=[bot-tpm-test], principals=[-teleport-internal-join], generation=0 tbot/service_bot_identity.go:223
```
  • Loading branch information
timothyb89 authored Jul 26, 2024
1 parent fb6b435 commit 70b603c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/tbot/output_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,16 @@ func describeTLSIdentity(ctx context.Context, log *slog.Logger, ident *identity.
}
}

botDesc := ""
if tlsIdent.BotInstanceID != "" {
botDesc = fmt.Sprintf(", id=%s", tlsIdent.BotInstanceID)
}

duration := cert.NotAfter.Sub(cert.NotBefore)
return fmt.Sprintf(
"valid: after=%v, before=%v, duration=%s | kind=tls, renewable=%v, disallow-reissue=%v, roles=%v, principals=%v, generation=%v",
"%s%s | valid: after=%v, before=%v, duration=%s | kind=tls, renewable=%v, disallow-reissue=%v, roles=%v, principals=%v, generation=%v",
tlsIdent.BotName,
botDesc,
cert.NotBefore.Format(time.RFC3339),
cert.NotAfter.Format(time.RFC3339),
duration,
Expand Down

0 comments on commit 70b603c

Please sign in to comment.