Skip to content

Conversation

@a-h
Copy link

@a-h a-h commented Sep 5, 2022

When you're building Lambda functions with CDK, you can't always guess the log prefix, and even if you can, it's a bit unweildy.

For example, with a CDK stack with logical ID "NodeCountExampleAwsLambdaStack" and a Lambda function called "CountGetFunction", CDK generates a CloudWatch Log Group of:

/aws/lambda/NodeCountExampleAwsLambda-CountGetFunctionD35D8410-

Note how "NodeCountExampleAwsLambdaStack" is truncated to "NodeCountExampleAwsLambda". There are also limits on the function logical ID.

To save me from having to use saw groups | grep CountGet, then copy / paste the outputted group name so that I can run saw get <groupname>, I thought it would be helpful to be able to "fuzzy search" the group name.

So in this PR, I've implemented a basic "contains substring" search for the log group that's only triggered when a --fuzzy flag is set.

You can get the logs directly with:

saw --fuzzy CountGet

Compared to:

saw get /aws/lambda/NodeCountExampleAwsLambda-CountGetFunctionD35D8410....

Obviously, it costs a CloudWatch Log API call or two if you use the fuzzy search flag, but it's not the default behaviour so won't affect anyone that doesn't use it.

@TylerBrock
Copy link
Owner

very nice -- I will take a look when I get some time to do so, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants