11
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AWS で必要最小限の権限、を求められた時

Last updated at Posted at 2025-02-22

必要最小限の権限?

よく求められますよね。
しかし、AWS のドキュメントをひっくり返して全部読むのも苦行です。

そうだ、作ったあとに追いかければええやん

AWS には AWS Cloudtrail という API を叩いたらログが残る仕組みがあります。
そして、AWS Cloudtrail は Amazon Athena というログを SQL で終える仕組みがありますよね。

であれば、AdministratorAccess 必要最小限の権限のユーザーやロールで実行したあと、そのエンティティが叩いた API を記録すれば!?

という感じでこんな SQL で回収できました。

select
  useridentity.sessionContext.sessionIssuer.username,
  eventsource,
  eventname,
  requestparameters
from 
  {Cloudtrail のテーブル}
where
  awsregion = {REGION}
  and eventtime like {2025-02-22T12:0% 的な時刻を絞る}
  and useridentity.sessionContext.sessionIssuer.username = {IAM のエンティティの名前}

必要に応じて distinct とかいろいろしましょうね

ちゃんちゃん

11
9
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
11
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?