0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

CloudTrailのtrailを、管理イベントを「書き込み」だけで作成するCFnテンプレート

Last updated at Posted at 2024-01-24

はじめに

CloudTrailの証跡をデフォルトで作成すると、管理イベントのAPIアクティビティは読み取りと書き込みの両方が記録されます。AWSリソースの変更操作だけ記録したい場合「書き込み」だけに設定するケースのために、CFnテンプレートを試してみました。

デフォルト設定

AWS公式にはEventSelectorを指定しない場合、デフォルトで管理イベントの「読み取り」と「書き込み」が設定されるとあります。

実際に特になにも設定せずにtrailを作成すると下記の設定になっています。

image.png

EventSelector

管理イベントを「書き込み」のみにする設定について、明確な記述は確認できませんでしたが、どうやらEventoSelectorでDataResourceを指定せずに、ReadWriteTypeを「WriteOnly」と指定することで、設定できるそうな感じでしたので、試してみました。

CFnテンプレート

trailWriteOnly_sample.yaml
AWSTemplateFormatVersion: "2010-09-09"

Resources:
  MyTrail:
    Type: AWS::CloudTrail::Trail
    Properties:
      S3BucketName: <your bucket name>
      IsLogging: true
      IsMultiRegionTrail: true
      EnableLogFileValidation: true
      IncludeGlobalServiceEvents: true
      TrailName: my-trail
      EventSelectors:
        - ReadWriteType: WriteOnly
          IncludeManagementEvents: true
          DataResources: []

デプロイ後

S3バケットの作成と、バケットポリシーの設定は省略

CloudFormationで容易したCFnテンプレートでデプロイ後に、作成されたtrailを確認
image.png

image.png

image.png

無事、管理イベントのAPIアクティビティが「書き込み」のみに設定されていることを確認できました。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?