Check for Patch Compliance for EC2 instance in multiple AWS environments?
#!/bin/bash # List of AWS profiles profiles=("profile1" "profile2" "profile3" "profile4") # Iterate through each AWS profile for profile in "${profiles[@]}"; do echo "Executing commands with AWS profile: $profile" # Set the AWS profile for the current iteration export AWS_PROFILE="$profile" # Step 0: Get all regions in the AWS account. for region_name in $(aws ec2 describe-regions --query "Regions[].{Name:RegionName}" --output text); do echo "Checking the region: $region_name" # Step 1: Get List of Instances in the Region instances_info=$(aws ec2 describe-instances --region "$region_name" --query 'Reservations[].Instances[].[InstanceId, Tags[?Key==`Name`].Value | [0]]' --output text) # Step 2: Loop Through Instances IFS=$'\n' for instance in $(echo "${instances_info}"); do ins...