Last active
February 2, 2017 20:21
-
-
Save jrab89/79bb5ec91d8de1ee344354c5572e9156 to your computer and use it in GitHub Desktop.
Digging through CloudTrail logs
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 characters
aws s3 sync \ | |
s3://your-cloudtrail/AWSLogs/222222bbbbbb/CloudTrail/us-east-1/YYYY/MM/DD/ \ | |
~/s3/your-cloudtrail/AWSLogs/222222bbbbbb/CloudTrail/us-east-1/YYYY/MM/DD/ | |
ag -lz \ | |
c11db0a3-7309-4089-9750-3835fb522e9d \ | |
~/s3/your-cloudtrail/AWSLogs/222222bbbbbb/CloudTrail/us-east-1/YYYY/MM/DD/ | |
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 characters
require 'json' | |
paths = Dir.glob("#{ENV['HOME']}/s3/your-cloudtrail/AWSLogs/222222bbbbbb/CloudTrail/us-east-1/YYYY/MM/DD/*.json.gz") | |
events = paths.flat_map do |path| | |
JSON.parse(Zlib::GzipReader.new(StringIO.new(File.read(path))).read)['Records'] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment