Posts

Showing posts with the label Linux
Image
AWS Infrastructure Inventory Discovery Blog Streamline Your AWS Inventory with Automated Discovery and Reporting Managing resources across multiple AWS accounts and regions can be a daunting task, especially as your cloud infrastructure grows. To simplify this process, I have developed an AWS Inventory Discovery tool that scans all your AWS accounts across all regions and compiles a comprehensive, searchable HTML report. In this blog, I'll walk you through the features, benefits, and the technical details of this solution. Introduction As organizations scale their use of AWS, keeping track of resources scattered across various accounts and regions becomes increasingly challenging. Manual inventory management is not only time-consuming but also prone to errors. This is where the AWS Inventory Discovery tool comes in. Features Comprehensive Scanning : The tool scans all your AWS accounts across all regions, ensu...

Get Unused AWS Load Balancer and Target health status

#!/bin/bash RED='\033[0;31m' NC='\033[0m' GREEN='\033[0;32m' BLUE='\033[0;34m' YELLOW='\033[33m' LZ_ENVIRONMENT="$1" REGION="$2" TIMESTAMP=$(date "+%F %T") #Get Authorisation echo -e "${BLUE}Authorising...${NC}" # Function to get all load balancer ARNs get_load_balancer_arns() { aws elbv2 describe-load-balancers --region "$REGION" --query 'LoadBalancers[*].LoadBalancerArn' --output json | jq -r '.[]' } # Function to get target group ARNs for a load balancer get_target_group_arns() { local lb_arn="$1" aws elbv2 describe-target-groups --region "$REGION" --load-balancer-arn "$lb_arn" --query 'TargetGroups[*].TargetGroupArn' --output json | jq -r '.[]' } # Function to check target health for a load balancer check_load_balancer_health() { local lb_arn="$1" local target_group_arns=($(get_target_group_arns ...

AMI Age Calculator of Running AWS EC2 Instances and Generate CSV Report

#!/bin/bash # Initialize variables with default values ACCOUNTID="<Your AccountID>" REGION="<Your Region>" OUTPUT_CSV="$ACCOUNTID-$REGION-ami_age_report.csv" # Define the CSV file name rm -rf $OUTPUT_CSV # Parse command line options while getopts "a:b:" option; do case $option in a) ACCOUNTID=${OPTARG} ;; b) REGION=${OPTARG} ;; *) echo "usage: $0 [-a ACCOUNTID] [-b REGION]" >&2 exit 1 ;; esac done # List instances and AMI IDs in the specified region instances_json=$(aws ec2 describe-instances --region "$REGION" --query 'Reservations[*].Instances[*].[InstanceId,ImageId]' --output json) # For local # Get the current timestamp current_time=$(date -u +%s) # Initialize the CSV file with headers echo "AccountID,Region,InstanceID,AMIID,AMIAge (months)" > "$OUTPUT_CSV" # Iterate through instances and append to the CSV file for row in $(echo "$insta...