cdk logs
eladb opened this issue · 2 comments
PR | Champion |
---|---|
# |
Description
$ cdk deploy
...
$ cdk logs
[construct path] [timestamp] text
[consrruct path] [timestamp] text
This command will query all the log groups in the CDK all from CloudWatch Logs and will print all the log events starting from deployment end time until now.
$ cdk logs --follow|-f
Will continue to stream incoming logs from CloudWatch every few seconds.
We will need to add framework support for registering log groups by L2 resources:
class lambda.Function {
constructor() {
// ...
Stack.of(this).addLogs(Logs.fromCloudWatch(`lambda/{this.functionName}`);
}
}
Since the log group name is likely to include deploy-bound values (such as the AWS Lambda function name), the addLogs()
method will simply add a CfnOutput
to the stack which will include comma-separated names of all the log groups in this app. The output will have a well known name which the CLI will use to query the log groups associated with this app.
Progress
- Tracking Issue Created
- RFC PR Created
- Core Team Member Assigned
- Initial Approval / Final Comment Period
- Ready For Implementation
- implementation issue 1
- Resolved
I've implemented a similar mechanism in CDK-Watch which derives the function names by looking up the resource in CF using its logical ID. You should be able to run cdkw logs "Path/To/API/**"
to match all lambdas under this path and poll their log streams.
I'm also experimenting with adding a Lambda Extension that forwards logs onto an APIGW WebSocket API, allowing for real-time lambda logs in the CLI.