-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Description
It would be amazing if running cdk watch
would trace the logs of the deployed Lambda Function/ECS Service/... directly into the customer's console, without the need for going to CloudWatch.
Use Case
The use case here is if I am using cdk watch
to iterate on code changes to a Lambda Function (or ECS service, etc) I want to be able to view the logs from that Function directly in my terminal. This will help in debugging my application without having to navigate to the CloudWatch logs console.
Proposed Solution
There are a couple different ways we could go about implementing this feature. Should this be a watch
specific feature, or a general logs feature similar to sam logs
? Suppose we had a CDK application that had 10 different Lambda Functions. When we run cdk watch
what do we want to happen?
Solution 1 - watch
specific feature:
In this solution we only want to stream logs for the resources that are being hotswapped. So in our above example, if we had 10 Lambda functions and we make a change to 1 Function, we should only see the logs for that 1 function.
- Logs would appear as part of the same terminal output as the rest of
cdk watch
- For Lambda Functions we could automatically determine the associated log group based on the function name. (i.e. /aws/lambda/function-name).
- For ECS Services we could determine the log group based on the container definition, but not all ECS services have to use CloudWatch logs.
{
"TaskDef": {
"Type": "AWS::ECS::TaskDefinition",
"Properties": {
"ContainerDefinitions": [{
"LogConfiguration": {
"Options": {
"awslogs-group": {
"Ref": "LogGroup"
}
}
}
}]
}
}
}
- For other things this could get more difficult. What "logs" do we want to stream for a stepfunction state machine? Should we stream the logs from individual components of the state machine (i.e. if the stepfunction calls a Lambda function)? Or should we stream back the actual state machine execution? Or both?
Other Solutions
We could also stream all logs from all hotswappable resources in the application, but this could become too verbose.
Alternatively we could ask the user for input on which CloudWatch log groups to monitor, i.e.
cdk watch --log-groups abc,xyz
Other information
No response
Acknowledge
- I may be able to implement this feature request
- This feature might incur a breaking change