#!/bin/bash # Check if jq is installed if ! command -v jq &> /dev/null then echo "jq is not installed. Please install jq to use this script." exit 1 fi # Check if a search term is provided if [ "$#" -ne 1 ]; then echo "Usage: $0 " exit 1 fi SEARCH_TERM="$1" # Generate a timestamp for the filename TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S") OUTPUT_FILE="lambda_bookmarks_${TIMESTAMP}.html" # Start Netscape Bookmark File echo "" > "$OUTPUT_FILE" echo "" >> "$OUTPUT_FILE" echo "" >> "$OUTPUT_FILE" echo "Bookmarks" >> "$OUTPUT_FILE" echo "

Bookmarks

" >> "$OUTPUT_FILE" echo "

" >> "$OUTPUT_FILE" # Get all Lambda functions and filter by the provided search term echo "Fetching Lambda functions..." aws lambda list-functions --query "Functions[?contains(FunctionName, \`${SEARCH_TERM}\`)]" --output json | jq -c '.[]' | while read -r function; do FUNCTION_NAME=$(echo "$function" | jq -r '.FunctionName') REGION=$(aws configure get region) # Generate CloudWatch Logs link LOG_GROUP="/aws/lambda/$FUNCTION_NAME" CLOUDWATCH_LOGS_URL="https://${REGION}.console.aws.amazon.com/cloudwatch/home?region=${REGION}#logsV2:log-groups/log-group/${LOG_GROUP//\//%2F}" # Generate Lambda function link LAMBDA_FUNCTION_URL="https://${REGION}.console.aws.amazon.com/lambda/home?region=${REGION}#/functions/${FUNCTION_NAME}?tab=code" # Append Lambda function and CloudWatch links to the bookmark file echo "

${FUNCTION_NAME}

" >> "$OUTPUT_FILE" echo "

" >> "$OUTPUT_FILE" echo "

CloudWatch Logs" >> "$OUTPUT_FILE" echo "
Lambda Function" >> "$OUTPUT_FILE" echo "

" >> "$OUTPUT_FILE" done # Close Netscape Bookmark File echo "

" >> "$OUTPUT_FILE" echo "Bookmarks saved to $OUTPUT_FILE"