Last active
November 22, 2024 17:44
-
-
Save parallaxisjones/ada2992b0b32760bf6472575ac668ec7 to your computer and use it in GitHub Desktop.
Revisions
-
parallaxisjones revised this gist
Nov 21, 2024 . 1 changed file with 16 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,18 @@ #!/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 <search-term>" exit 1 fi SEARCH_TERM="$1" # Generate a timestamp for the filename @@ -36,4 +51,4 @@ done # Close Netscape Bookmark File echo "</DL><p>" >> "$OUTPUT_FILE" echo "Bookmarks saved to $OUTPUT_FILE" -
parallaxisjones created this gist
Nov 20, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ 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 "<!DOCTYPE NETSCAPE-Bookmark-file-1>" > "$OUTPUT_FILE" echo "<!-- This is an automatically generated file. -->" >> "$OUTPUT_FILE" echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">" >> "$OUTPUT_FILE" echo "<TITLE>Bookmarks</TITLE>" >> "$OUTPUT_FILE" echo "<H1>Bookmarks</H1>" >> "$OUTPUT_FILE" echo "<DL><p>" >> "$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 " <DT><H3>${FUNCTION_NAME}</H3>" >> "$OUTPUT_FILE" echo " <DL><p>" >> "$OUTPUT_FILE" echo " <DT><A HREF=\"${CLOUDWATCH_LOGS_URL}\" ADD_DATE=\"$(date +%s)\">CloudWatch Logs</A>" >> "$OUTPUT_FILE" echo " <DT><A HREF=\"${LAMBDA_FUNCTION_URL}\" ADD_DATE=\"$(date +%s)\">Lambda Function</A>" >> "$OUTPUT_FILE" echo " </DL><p>" >> "$OUTPUT_FILE" done # Close Netscape Bookmark File echo "</DL><p>" >> "$OUTPUT_FILE" echo "Bookmarks saved to $OUTPUT_FILE"