This is a blank project for CDK development with TypeScript.
The cdk.json
file tells the CDK Toolkit how to execute your app.
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template
Before deploying the Lambda function, it's essential to understand how to invoke it:
-
Dry Run: To test the Lambda function without actually deleting any Log Groups, invoke it with the following event:
{ "cleanup": false }
This will allow the function to identify unused Log Groups and log them without performing any deletions.
-
Actual Cleanup: Once you're confident with the dry run results and want to proceed with the actual cleanup, invoke the Lambda function with:
{ "cleanup": true }
This will command the function to delete the identified unused CloudWatch Log Groups.
aws lambda invoke --function-name YourFunctionName --payload '{"cleanup": false}' outputfile.txt
To see the logs tail you can use the following aws cli command:
aws logs tail /aws/lambda/YourFunctionName --follow
Happy coding ;)