Skip to content
Latchkey

aws logs tail: Stream CloudWatch Logs in CI

Tail or fetch recent CloudWatch Logs for a log group from the CLI.

aws logs tail prints recent CloudWatch Logs events for a group and can follow them live. In CI it surfaces Lambda, ECS, or application logs right after a deploy to verify behavior or capture failure output without opening the console.

Common flags

  • --follow - stream new events as they arrive
  • --since 10m - start from a relative time (e.g. 1h, 30m)
  • --filter-pattern "ERROR" - only show matching events
  • --format short - compact output without metadata

Example in CI

Pull the last 5 minutes of error logs after a deploy.

shell
aws logs tail /aws/lambda/my-api --since 5m --filter-pattern "ERROR"

Common errors in CI

  • An error occurred (ResourceNotFoundException) - log group does not exist yet
  • An error occurred (AccessDeniedException) - role lacks logs:GetLogEvents/FilterLogEvents
  • No output - events have not propagated yet, or --since window is too short

Key takeaways

  • aws logs tail fetches recent events; add --follow to stream live.
  • Use --since and --filter-pattern to scope a post-deploy log check in CI.
  • A missing log group (ResourceNotFoundException) usually means it has not been invoked yet.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →