Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add fuzzy searching for log group names #72

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

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