0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

全リージョンのCloudTrailのログを検索する

Last updated at Posted at 2024-09-14

概要

  • 調査で利用した
  • AWSコンソールだとリージョンごとにフィルタしないと確認できないから面倒なのでAWS CLIを利用する
  • その時のメモ

準備

  • Dockerでやった
  • 認証情報は試したディレクトリに aws/config を用意した
$ mkdir aws
$ touch aws/config

# 内容保存(省略)

$ cat aws/config
[default]
aws_access_key_id = xxx
aws_secret_access_key = yyy

作ったやつ

#!/bin/bash

ALL_REGION=(`docker run --rm -w /app -e AWS_PAGER="" -v $(pwd):/app -v $(pwd)/aws:/root/.aws -it amazon/aws-cli:latest --region us-west-1 ec2 describe-regions --all-regions --query 'Regions[].[RegionName]' --output text`)
for region in ${ALL_REGION[@]}
do
    echo '-----------'
    echo "[${region}]"
    docker run --rm -w /app -e AWS_PAGER="" -v $(pwd):/app -v $(pwd)/aws:/root/.aws -it amazon/aws-cli:latest cloudtrail lookup-events --lookup-attributes "AttributeKey=EventName,AttributeValue=StartLogging" --start-time 2024-01-01 --region ${region} --query "Events[*].[Username, EventName, EventTime, Resources]"
    echo '-----------'
done

Dockerのコマンド部分を変数にできたらもっと省略できそう(当時一旦よし!でやっちゃった)

補足

参考URL

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?