amazon web services - Retrieving Username from CloudTrail logs for RunInstances event -
we have large number of ec2 instances running in aws 1 year. trying perform clean activity unused instances , based on username using have launched instances. i have tried downloading cloudtrail logs s3 bucket , tried filtering username , 'runinstances' event may find user launched instance , instance details. the following script used download cloudtrail logs single folder, unzip them , filter instances 'runinstances' event , give count of instances. i need on retrieving usernames each log wiht 'runinstances' event , stopping instances. my script: #!bin/sh s3url="s3://s3bucket/awscloudtraillogs/<accountno>/cloudtrail/region/2016/" (( i=1; i<=12; i++ )) (( j=1; j<=31; j++ )) if [[ $i -le 9 && $j -le 9 ]] aws s3 cp $s3url/0$i/0$j/ ~/test/ --recursive elif [[ $i -le 9 && $j -ge 10 ]] aws s3 cp $s3url/0$i/$j/ ~/test/ --recursive elif [[ $i -ge ...