Skip to content

Instantly share code, notes, and snippets.

View ns-mkusper's full-sized avatar
👋

Mark Kusper ns-mkusper

👋
  • Chicago
View GitHub Profile
import boto3
from datetime import datetime, timedelta
regions = [
"ap-northeast-1", "ap-northeast-2", "ap-south-1", "ap-southeast-1",
"eu-central-1", "eu-west-1", "eu-west-2", "us-east-1", "us-east-2",
"us-west-1", "us-west-2"
]
for region in regions:
aws --output json cloudtrail lookup-events --lookup-attributes AttributeKey=ResourceName,AttributeValue="" | jq -r '.Events | .[] | "\(.EventTime| strftime("%F %T"))\t\(.Username)\t\(.EventName)\t\(.Resources[0].ResourceType)\t\(.Resources[0].ResourceName)"'
#!/usr/bin/env bash
# When sourced, this script will export the AWS_ACCESS_KEY_ID and
# AWS_SECRET_ACCESS_KEY env vars from a specific profile in
# ~/.aws/credentials.
# It will also set AWS_PROFILE and AWS_DEFAULT_PROFILE, ensuring
# the current shell is configured to use the correct AWS credentials
# regardless of what script or tools you are using to connect to AWS...
# boto, aws cli, ansible etc.