Skip to content

Add nextdeploy logs command to stream CloudWatch logs from Lambda #3

@aynaash

Description

@aynaash

Summary

Add a nextdeploy logs command that streams CloudWatch logs from the deployed Lambda function in real-time.

Expected Behavior

# Tail logs in real-time
nextdeploy logs --tail

# Show last 100 log lines
nextdeploy logs --lines 100

# Show logs from last 30 minutes
nextdeploy logs --since 30m

Implementation Notes

  • Use AWS CloudWatch Logs SDK (FilterLogEvents or GetLogEvents)
  • Lambda log group follows pattern: /aws/lambda/<function-name>
  • Function name is available from nextdeploy.yml config
  • Use polling with FilterLogEvents + nextToken for tail mode

Files to Create/Modify

  • cli/cmd/logs.go[NEW] Cobra command definition
  • cli/internal/serverless/aws_logs.go[NEW] CloudWatch Logs implementation
  • cli/cmd/root.go — Register the new command

Reference

  • Look at cli/cmd/ship.go for how AWS credentials are initialized
  • The AWSProvider struct in cli/internal/serverless/aws.go already has an AWS config

Difficulty: Medium · Language: Go

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions