AMS Accelerate アカウントの変更の追跡 - AMS Accelerate ユーザーガイド

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

AMS Accelerate アカウントの変更の追跡

重要

Change Record サービスは、2025 年 7 月 1 日をもって廃止されました。

新しいアカウントを Change Record サービスにオンボーディングすることはできません。

AMS Accelerate アカウントの CloudTrail データをクエリするには、次のサービスを使用できます。

  • で AWS CloudTrail、イベント履歴を選択し、ルックアップ属性を使用してイベントをフィルタリングします。時間範囲フィルターを使用して、s3.amazon.aws.com指定したイベントソースでイベント履歴をフィルタリングするか、ユーザー名でイベント履歴をフィルタリングするかを選択できます。詳細については、CloudTrail イベント履歴の使用」を参照してください。

  • AWS CloudTrail Lake を使用して、クエリを通じてデータを収集します。Lake AWS CloudTrail を選択しQuery を選択します。独自のクエリを作成したり、クエリジェネレーターを使用したり、サンプルクエリを使用してイベントベースのデータを収集したりできます。例えば、先週 Amazon EC2 インスタンスを削除したユーザーを尋ねることができます。詳細については、AWS CloudTrail 「ソースからデータレイクを作成する」およびCloudTrailLake クエリ」を参照してください。

  • で Amazon Athena テーブルを作成し AWS CloudTrail 、ストレージの場所を証跡に関連付けられた Amazon S3 バケットとして設定します。証跡のホームリージョンと Amazon S3 バケットが同じであることを確認します。Amazon Athena では、クエリエディタを使用して、Athena コンソールで使用するために Accelerate が提供するデフォルトのクエリを実行します。への Athena テーブルを作成して CloudTrail ログをクエリする方法の詳細については、「クエリ AWS CloudTrail ログ」を参照してください。

AWS Managed Services は、Amazon Athena (Athena) コンソールと AMS Accelerate ログ管理を使用してクエリ可能なインターフェイスを提供することで、AMS Accelerate Operations チームおよび AMS Accelerate Automation による変更を追跡するのに役立ちます。

Athena は、標準の構造化クエリ言語 (SQL) を使用して Amazon S3 内のデータを分析するために使用できるインタラクティブなクエリサービスです (Amazon Athena の SQL リファレンスを参照)。Athena はサーバーレスであることから管理するインフラストラクチャがなく、実行したクエリの料金のみを支払います。AMS Accelerate は、CloudTrail ログを介して毎日のパーティションを持つ Athena テーブルを作成し、プライマリ AWS リージョンと ams-change-record ワークグループ内でクエリを提供します。デフォルトのクエリのいずれかを選択し、必要に応じて実行できます。Athena ワークグループの詳細については、「ワークグループの仕組み」を参照してください。

注記

Accelerate が CloudTrail Organization 証跡と統合されている場合、Athena を使用して Accelerate アカウントの CloudTrail イベントをクエリできるのは Accelerate のみです。ただし、オンボーディング中に Athena を使用してアカウント内の CloudTrail イベントをクエリおよび分析するための IAM ロールを Organization 管理者がデプロイした場合を除きます。

変更レコードを使用すると、次のような質問に簡単に回答できます。

  • アカウントにアクセスしたユーザー (AMS Accelerate Systems または AMS Accelerate Operators)

  • アカウントで AMS Accelerate によってどのような変更が行われたか

  • AMS Accelerate がアカウントで変更を実行したのはいつですか

  • アカウントで行われた変更を表示する場所

  • AMS Accelerate がアカウントに変更を加える必要があった理由

  • クエリを変更して、AMS 以外の変更に対するすべての質問に対する回答を取得する方法

変更レコードの表示

Athena クエリを使用するには、 AWS マネジメントコンソールにサインインし、プライマリ AWS リージョンの Athena コンソールに移動します。

注記

いずれかのステップの実行中に Amazon Athena の開始方法ページが表示された場合は、開始方法 をクリックします。これは、変更レコードインフラストラクチャがすでに配置されている場合でも表示されることがあります。

  1. Athena コンソールの上部ナビゲーションパネルからワークグループを選択します。

  2. ams-change-record ワークグループを選択し、ワークグループの切り替えをクリックします。

  3. データベースコンボボックスから ams-change-record-database を選択します。ams-change-record-database には、ams-change-record-table テーブルが含まれています。

  4. 上部のナビゲーションパネルから保存されたクエリを選択します。

  5. 保存済みクエリウィンドウには、AMS Accelerate が提供するクエリのリストが表示され、これを実行できます。保存済みクエリリストから実行するクエリを選択します。例えば、ams_session_accesses_v1 クエリなどです。

    プリセット AMS Accelerate クエリの完全なリストについては、「」を参照してくださいデフォルトクエリ

  6. 必要に応じてクエリエディタボックスの日時フィルターを調整します。デフォルトでは、クエリは最終日からの変更のみをチェックします。

  7. [Run query] (クエリの実行) を選択します。

デフォルトクエリ

AMS Accelerate には、Athena コンソールで使用できるデフォルトのクエリがいくつか用意されています。デフォルトのクエリを次の表に示します。

注記
  • すべてのクエリは、日時範囲をオプションのフィルターとして受け入れます。すべてのクエリは、デフォルトで過去 24 時間にわたって実行されます。予想される入力については、次のサブセクション「」を参照してくださいクエリでの日時フィルターの変更

  • 変更できる、または変更する必要があるパラメータ入力は、角括弧付きの <PARAMETER_NAME> としてクエリに表示されます。プレースホルダー角括弧をパラメータ値に置き換えます。

  • すべてのフィルターはオプションです。クエリでは、一部のオプションのフィルターが行の先頭に二重ダッシュ (--) でコメントアウトされます。すべてのクエリは、デフォルトのパラメータを使用して、それらなしで実行されます。これらのオプションのフィルターにパラメータ値を指定する場合は、行の先頭にある二重ダッシュ (--) を削除し、必要に応じて パラメータを置き換えます。

  • すべてのクエリは出力IAM SessionIdIAM PincipalIdと を返します。

  • クエリを実行するための計算コストは、アカウントに対して生成される CloudTrail ログの数によって異なります。コストを計算するには、AWS Athena 料金計算ツールを使用します。

既定クエリ
目的/説明 入力 出力

クエリ名: ams_access_session_query_v1

AMS Accelerate アクセスセッションの追跡

特定の AMS Accelerate アクセスセッションに関する情報を提供します。クエリは IAM プリンシパル ID をオプションのフィルターとして受け入れ、イベント時間、アカウントへのアクセスのビジネスニーズ、リクエスタなどを返します。

行のコメントを解除し、プレースホルダー IAM PrincipalId をクエリエディタで特定の ID に置き換えることで、特定の IAM PrincipalIdプリンシパル ID をフィルタリングできます。

クエリの WHERE 句の useragent フィルターラインを削除して、AMS 以外のアクセスセッションを一覧表示することもできます。

(オプション) IAM PrincipalId: アクセスしようとしているリソースの IAM プリンシパル識別子。形式は UNIQUE_IDENTIFIERRESOURCE_NAME です。詳細については、「一意の識別子」を参照してください。このフィルターなしでクエリを実行して、 でフィルタリングする正確な IAM PrincipalId を決定できます。

  • EventTime: アクセスを取得する時刻

  • EventName: AWS イベント名 (AssumeRole)

  • EventRegion: リクエストを取得する AWS リージョン

  • EventId: CloudTrail イベント ID

  • BusinessNeed タイプ: アカウントにアクセスするためのビジネス上の理由タイプ。使用できる値は、SupportCase、OpsItem、Issue、Text です。

  • BusinessNeed: ビジネスはアカウントにアクセスする必要があります。例えば、Support Case ID、Ops Item ID などです。

  • リクエスタ: アカウントにアクセスするオペレーター ID、またはアカウントにアクセスするオートメーションシステム。

  • RequestAccessType: リクエスタタイプ (System、OpsConsole、OpsAPI、Unset)

クエリ名: ams_events_query_v1

AMS Accelerate によって行われたすべての変更アクションを追跡する

AMS Accelerate ロールフィルターを使用してアカウントで実行されたすべての書き込みアクションを返します。

また、クエリの WHERE 句から useridentity.arn フィルター行を削除することで、非 AMS ロールによって実行された変更アクションを追跡することもできます。

(オプション)

日時範囲のみ。「クエリでの日時フィルターの変更」を参照してください。

  • AccountId: AWS アカウント ID

  • RoleArn: リクエスタの RoleArn

  • EventTime: アクセスを取得する時刻

  • EventName: AWS イベント名 (AssumeRole)

  • EventRegion: リクエストを取得する AWS リージョン

  • EventId: CloudTrail イベント ID

  • RequestParameters : リクエストのリクエストパラメータ

  • ResponseElements: レスポンスのレスポンス要素。

  • UserAgent: AWS CloudTrail ユーザーエージェント

クエリ名: ams_instance_access_sessions_query_v1

AMS Accelerate によるインスタンスアクセスの追跡

AMS Accelerate インスタンスアクセスのリストを返します。すべてのレコードには、イベント時間、イベントリージョン、インスタンス ID、IAM プリンシパル ID、IAM セッション ID、SSM セッション ID が含まれます。IAM プリンシパル ID を使用して、Athena ams_access_sessions_query_v1 クエリを使用してインスタンスにアクセスするためのビジネスニーズの詳細を取得できます。SSM セッション ID を使用して、セッションの開始時刻と終了時刻、ログの詳細、インスタンスの AWS リージョンの AWS Session Manager コンソールの使用など、インスタンスアクセスセッションの詳細を取得できます。

ユーザーは、クエリの WHERE 句のユーザー ID フィルター行を削除して、AMS 以外のインスタンスアクセスを一覧表示することもできます。

datetime range のみ。「クエリでの日時フィルターの変更」を参照してください。

  • InstanceId: インスタンス ID

  • SSMSession ID: SSM セッション ID

  • RoleArn: リクエスタの RoleArn

  • EventTime: アクセスを取得する時刻

  • EventName: AWS イベント名 (AssumeRole)

  • EventRegion: リクエストを取得する AWS リージョン

  • EventId: CloudTrail イベント ID

クエリ名: ams_privilege_escalation_events_query_v1

AMS ユーザーと非 AMS ユーザーのアクセス許可 (エスカレーション) イベントを追跡する

直接、または特権エスカレーションにつながる可能性のあるイベントのリストを提供します。クエリは、オプションのフィルターとして ActionedBy を受け入れ、EventName、EventId、EventTime などを返します。イベントに関連付けられたすべてのフィールドも返されます。そのイベントに該当しない場合、フィールドは空白になります。ActionedBy フィルターはデフォルトで無効になっています。有効にするには、その行から「--」を削除します。

デフォルトでは、ActionedBy フィルターは無効になっています (すべてのユーザーからの特権エスカレーションイベントが表示されます)。特定のユーザーまたはロールのイベントを表示するには、WHERE 句のユーザー ID フィルターラインから二重ダッシュ (--) を削除し、プレースホルダー ACTIONEDBY_PUT_USER_NAME_HERE を IAM ユーザーまたはロール名に置き換えます。フィルターなしでクエリを実行して、フィルタリングする正確なユーザーを決定できます。

(オプション) ACTIONEDBY_PUT_USER_NAME: actionedBy ユーザーのユーザー名。これは IAM ロールまたはユーザーのいずれかです。例えば、ams-access-admin です。

(オプション) datetime range。「クエリでの日時フィルターの変更」を参照してください。

  • AccountId: アカウント ID

  • ActionedBy: ActionedBy ユーザー名

  • EventTime: アクセスを取得する時刻

  • EventName: AWS イベント名 (AssumeRole)。

  • EventRegion: リクエストを取得する AWS リージョン

  • EventId: CloudTrail イベント ID

クエリ名: ams_resource_events_query_v1

特定のリソース AMS または非 AMS の書き込みイベントを追跡する

特定のリソースで実行されたイベントのリストを提供します。クエリは、フィルターの一部としてリソース ID を受け入れ (クエリの WHERE 句でプレースホルダー RESOURCE_INFO を置き換える)、そのリソースに対して実行されたすべての書き込みアクションを返します。

(必須) RESOURCE_INFO: リソース識別子は、アカウント内の任意の AWS リソースの ID にすることができます。これをリソース ARNs と混同しないでください。たとえば、EC2 インスタンスのインスタンス ID、DynamoDB テーブルのテーブル名、CloudWatch Log の logGroupName などです。

(オプション) datetime range。「クエリでの日時フィルターの変更」を参照してください。

  • AccountId: アカウント ID

  • ActionedBy: ActionedBy ユーザー名

  • EventTime: アクセスを取得する時刻

  • EventName: AWS イベント名 (AssumeRole)。

  • EventRegion: リクエストを取得する AWS リージョン

  • EventId: CloudTrail イベント ID

クエリ名: ams_session_events_query_v1

特定のセッション中に AMS Accelerate によって実行された書き込みアクションを追跡する

特定のセッションで実行されたイベントのリストを提供します。クエリは、フィルターの一部として IAM プリンシパル ID を受け入れ (クエリの WHERE 句でプレースホルダー PRINCIPAL_ID を置き換える)、そのリソースに対して実行されたすべての書き込みアクションを返します。

(必須) PRINCIPAL_ID: セッションのプリンシパル ID。形式は UNIQUE_IDENTIFIERRESOURCE_NAME です。詳細については、「一意の識別子」を参照してください。クエリ「ams_session_ids_by_requester_v1IDs のリストを取得できます。このフィルターなしでクエリを実行して、フィルタリングする正確な IAM PrincipalId を決定することもできます。

(オプション) datetime range。「クエリでの日時フィルターの変更」を参照してください。

  • AccountId: アカウント ID

  • ActionedBy: ActionedBy ユーザー名

  • EventTime: アクセスを取得する時刻

  • EventName: AWS イベント名 (AssumeRole)

  • EventRegion: リクエストを取得する AWS リージョン

  • EventId: CloudTrail イベント ID

クエリ名: ams_session_ids_by_requester_v1

特定のリクエスタの IAM プリンシパル/セッション IDs を追跡します。

クエリは「リクエスタ」を受け入れ (クエリの WHERE 句でプレースホルダーリクエスタを置き換える)、指定された時間範囲内でリクエスタによってすべての IAM プリンシパル ID を返します。

(必須) Requester: アカウントにアクセスするオペレータ ID (オペレータのエイリアスなど)、またはアカウントにアクセスするオートメーションシステム (OsConfiguration、AlarmManager など)。

(オプション) datetime range。「クエリでの日時フィルターの変更」を参照してください。

  • IAM PrincipalId - セッションの IAM プリンシパル ID。形式は UNIQUE_IDENTIFIERRESOURCE_NAME です。詳細については、「一意の識別子」を参照してください。このフィルターなしでクエリを実行して、フィルタリングする正確な IAM PrincipalId を決定できます。

  • IAM SessionId - アクセスセッションの IAM セッション ID

  • EventTime: アクセスを取得する時刻

クエリでの日時フィルターの変更

すべてのクエリは、日時範囲をオプションのフィルターとして受け入れます。デフォルトでは、すべてのクエリは過去 1 日間に実行されます。

日時フィールドに使用される形式は yyyy/MM/dd (例: 2021/01/01) です。タイムスタンプ全体ではなく、日付のみを保存することに注意してください。タイムスタンプ全体については、フィールド eventime を使用します。このフィールドには、ISO 8601 形式 yyyy-MM-ddT HH:mm:ssZ (例: 2021-01-01T23:59:59Z) でタイムスタンプが格納されます。ただし、テーブルは日時フィールドでパーティション化されているため、日時フィルターとイベント時フィルターの両方をクエリに渡す必要があります。次の 例を参照してください。

注記

範囲を変更できる受け入れられたすべての方法を確認するには、日付と時刻の関数と演算子に現在使用されている Athena エンジンバージョンに基づく最新の Presto 関数ドキュメントを参照して、範囲を変更できる受け入れられたすべての方法を確認してください。

日付レベル: 過去 1 日または過去 24 時間 (デフォルト) の例: CURRENT_DATE='2021/01/01' の場合、フィルターは現在の日付から 1 日を引いて日時 > '2020/12/31' としてフォーマットします

datetime > date_format(date_add('day', - 1, CURRENT_DATE), '%Y/%m/%d')

日付レベル: 過去 2 か月の例:

datetime > date_format(date_add('month', - 2, CURRENT_DATE), '%Y/%m/%d')

日付レベル: 2 つの日付の間の例:

datetime > '2021/01/01' AND datetime < '2021/01/10'

タイムスタンプレベル: 過去 12 時間の例:

過去 1 日にスキャンされたデータをパーティション化し、過去 12 時間以内にすべてのイベントをフィルタリングする

datetime > date_format(date_add('day', - 1, CURRENT_DATE), '%Y/%m/%d') AND eventtime > date_format(date_add('hour', - 12, CURRENT_TIMESTAMP), '%Y-%m-%dT%H:%i:%sZ')

タイムスタンプレベル: 2 つのタイムスタンプの間の例:

2021 年 1 月 1 日午後 12 時~2021 年 1 月 10 日午後 3 時の間にイベントを取得します。

datetime > '2021/01/01' AND datetime < '2021/01/10' AND eventtime > '2021-01-01T12:00:00Z' AND eventtime < '2021-01-10T15:00:00Z'

デフォルトのクエリ例

Name: ams_access_session_query_v1 Description: >- The query provides more information on specific AMS access session. The query accepts IAM Principal Id as an optional filter and returns event time, business need for accessing the account, requester, ... etc. By default; the query filter last day events only, the user can change the datetime filter to search for more wide time range. By default; the IAM PrincipalId filter is disabled. To enable it, remove "-- " from that line. AthenaQueryString: |- /* The query provides list of AMS access sessions during specific time range. The query accepts IAM Principal Id as an optional filter and returns event time, business need for accessing the account, requester, ... etc. By default, the query filters the last day's events only; you can change the "datetime" filter to search for a wider time range. By default; the IAM Principal ID filter is disabled (it shows access sessions for all IAM principals). If you want to only show access sessions for a particular IAM principal ID, remove the double-dash (--) from the "IAM Principal ID" filter line in the WHERE clause of the query, and replace the placeholder "<IAM PrincipalId>" with the specific ID that you want. You can run the query without the filter to determine the exact IAM PrincipalId you want to filter with. By default; the query only shows AMS access sessions. If you also want to show non-AMS access sessions, remove the "useragent" filter in the WHERE clause of the query. For expected inputs and scenarios, refer to AMS Documentation -> Tracking changes in your AMS Accelerate accounts -> Default Queries */ SELECT json_extract_scalar(responseelements, '$.assumedRoleUser.assumedRoleId') AS "IAM PrincipalId", json_extract_scalar(responseelements, '$.credentials.accessKeyId') AS "IAM SessionId", eventtime AS "EventTime", eventname AS "EventName", awsregion AS "EventRegion", eventid AS "EventId", json_extract_scalar(requestparameters, '$.tags[0].value') AS "BusinessNeed", json_extract_scalar(requestparameters, '$.tags[1].value') AS "BusinessNeedType", json_extract_scalar(requestparameters, '$.tags[2].value') AS "Requester", json_extract_scalar(requestparameters, '$.tags[3].value') AS "AccessRequestType" FROM "{DATABASE NAME HERE}".{TABLENAME HERE} <- This should auto-populate WHERE datetime > date_format(date_add('day', - 1, CURRENT_DATE), '%Y/%m/%d') AND eventname = 'AssumeRole' AND useragent = 'access.managedservices.amazonaws.com' -- AND json_extract_scalar(responseelements, '$.assumedRoleUser.assumedRoleId') = '<IAM PrincipalId>' ORDER BY eventtime InsightsQueryString: |- # The query provides list of AMS access sessions during specific time range. # The query accepts IAM Principal Id as an optional filter and returns event time, business need for accessing the account, requester, ... etc. # # By default; the IAM Principal ID filter is disabled (it shows access sessions for all IAM principals). # If you want to only show access sessions for a particular IAM principal ID, remove the # (#) from # the "IAM Principal ID" filter of the query, and replace the placeholder "<IAM PrincipalId>" with the specific ID that you want. # You can run the query without the filter to determine the exact IAM PrincipalId you want to filter with. # # By default; the query only shows AMS access sessions. If you also want to show non-AMS access sessions, # remove the "useragent" filter from the query. # # For expected inputs and scenarios, refer to AMS Documentation -> Tracking changes in your AMS Accelerate accounts -> Default Queries filter eventName="AssumeRole" AND userAgent="access.managedservices.amazonaws.com" # | filter responseElements.assumedRoleUser.assumedRoleId= "<IAM PrincipalId>" | sort eventTime desc | fields responseElements.assumedRoleUser.assumedRoleId as IAMPrincipalId, responseElements.credentials.accessKeyId as IAMSessionId, eventTime as EventTime, eventName as EventName, awsRegion as EventRegion, eventID as EventId, requestParameters.tags.0.value as BusinessNeed, requestParameters.tags.1.value as BusinessNeedType, requestParameters.tags.2.value as Requester, requestParameters.tags.3.value as AccessRequestType
ams_events_query_v1.yaml /* The query provides list of events to track write actions for all AMS changes. The query returns all write actions done on the account using that AMS role filter. By default, the query filters the last day's events only; you can change the "datetime" filter to search for a wider time range. You can also track mutating actions done by non-AMS roles by removing the "useridentity.arn" filter lines from the WHERE clause of the query. For expected inputs and scenarios, refer to AMS Documentation -> Tracking changes in your AMS Accelerate accounts -> Default Queries */ SELECT useridentity.principalId AS "IAM PrincipalId", useridentity.accesskeyid AS "IAM SessionId", useridentity.accountid AS "AccountId", useridentity.arn AS "RoleArn", eventid AS "EventId", eventname AS "EventName", awsregion AS "EventRegion", eventsource AS "EventService", eventtime AS "EventTime", requestparameters As "RequestParameters", responseelements AS "ResponseElements", useragent AS "UserAgent" FROM "{DATABASE NAME HERE}".{TABLENAME HERE} <- This should auto-populate WHERE readonly <> 'true' AND ( LOWER(useridentity.arn) LIKE '%/ams%' OR LOWER(useridentity.arn) LIKE '%/customer_ssm_automation_role%' ) ORDER BY eventtime
ams_instance_access_sessions_query_v1 /* The query provides list of AMS Instance accesses during specific time range. The query returns the list of AMS instance accesses; every record includes the event time, the event AWS Region, the instance ID, the IAM session ID, and the SSM session ID. You can use the IAM Principal ID to get more details on the business need for accessing the instance by using ams_access_session_query_v1 athena query. You can use the SSM session ID to get more details on the instance access session, including the start and end time of the session and log details, using the AWS Session Manager Console in the instance's AWS Region. You can also list non-AMS instance accesses by removing the "useridentity" filter line in the WHERE clause of the query. By default, the query filters the last day's events only; you can change the "datetime" filter to search for a wider time range. For expected inputs and scenarios, refer to AMS Documentation -> Tracking changes in your AMS Accelerate accounts -> Default Queries */ SELECT useridentity.principalId AS "IAM PrincipalId", useridentity.accesskeyid AS "IAM SessionId", json_extract_scalar(requestparameters, '$.target') AS "InstanceId", json_extract_scalar(responseelements, '$.sessionId') AS "SSM SessionId", eventname AS "EventName", awsregion AS "EventRegion", eventid AS "EventId", eventsource AS "EventService", eventtime AS "EventTime" FROM "{DATABASE NAME HERE}".{TABLENAME HERE} <- This should auto-populate WHERE useridentity.sessionContext.sessionIssuer.arn like '%/ams_%' AND eventname = 'StartSession' ORDER BY eventtime
ams_privilege_escalation_events_query_v1.yaml /* The query provides list of events that can directly or potentially lead to a privilege escalation. The query accepts ActionedBy as an optional filter and returns EventName, EventId, EventTime, ... etc. All fields associated with the event are also returned. Some fields are blank if not applicable for that event. You can use the IAM Session ID to get more details about events happened in that session by using ams_session_events_query_v1 query. By default, the query filters the last day's events only; you can change the "datetime" filter to search for a wider time range. By default, the ActionedBy filter is disabled (it shows privilege escalation events from all users). To show events for a particular user or role, remove the double-dash (--) from the useridentity filter line in the WHERE clause of the query and replace the placeholder "<ACTIONEDBY_PUT_USER_NAME_HERE>" with an IAM user or role name. You can run the query without the filter to determine the exact user you want to filter with. For expected inputs and scenarios, refer to AMS Documentation -> Tracking changes in your AMS Accelerate accounts -> Default Queries */ SELECT useridentity.principalId AS "IAM PrincipalId", useridentity.accesskeyid AS "IAM SessionId", useridentity.accountid AS "AccountId", reverse(split_part(reverse(useridentity.arn), ':', 1)) AS "ActionedBy", eventname AS "EventName", awsregion AS "EventRegion", eventid AS "EventId", eventtime AS "EventTime", json_extract_scalar(requestparameters, '$.userName') AS "UserName", json_extract_scalar(requestparameters, '$.roleName') AS "RoleName", json_extract_scalar(requestparameters, '$.groupName') AS "GroupName", json_extract_scalar(requestparameters, '$.policyArn') AS "PolicyArn", json_extract_scalar(requestparameters, '$.policyName') AS "PolicyName", json_extract_scalar(requestparameters, '$.permissionsBoundary') AS "PermissionsBoundary", json_extract_scalar(requestparameters, '$.instanceProfileName') AS "InstanceProfileName", json_extract_scalar(requestparameters, '$.openIDConnectProviderArn') AS "OpenIDConnectProviderArn", json_extract_scalar(requestparameters, '$.serialNumber') AS "SerialNumber", json_extract_scalar(requestparameters, '$.serverCertificateName') AS "ServerCertificateName", json_extract_scalar(requestparameters, '$.accessKeyId') AS "AccessKeyId", json_extract_scalar(requestparameters, '$.certificateId') AS "CertificateId", json_extract_scalar(requestparameters, '$.newUserName') AS "NewUserName", json_extract_scalar(requestparameters, '$.newGroupName') AS "NewGroupName", json_extract_scalar(requestparameters, '$.newServerCertificateName') AS "NewServerCertificateName", json_extract_scalar(requestparameters, '$.name') AS "SAMLProviderName", json_extract_scalar(requestparameters, '$.sAMLProviderArn') AS "SAMLProviderArn", json_extract_scalar(requestparameters, '$.sSHPublicKeyId') AS "SSHPublicKeyId", json_extract_scalar(requestparameters, '$.virtualMFADeviceName') AS "VirtualMFADeviceName" FROM "{DATABASE NAME HERE}".{TABLENAME HERE} <- This should auto-populate WHERE ( -- More event names can be found at https://docs.aws.amazon.com/IAM/latest/UserGuide/list_identityandaccessmanagement.html eventname LIKE 'Add%' OR eventname LIKE 'Attach%' OR eventname LIKE 'Delete%' AND eventname != 'DeleteAccountAlias' OR eventname LIKE 'Detach%' OR eventname LIKE 'Create%' AND eventname != 'CreateAccountAlias' OR eventname LIKE 'Put%' OR eventname LIKE 'Remove%' OR eventname LIKE 'Update%' OR eventname LIKE 'Upload%' OR eventname = 'DeactivateMFADevice' OR eventname = 'EnableMFADevice' OR eventname = 'ResetServiceSpecificCredential' OR eventname = 'SetDefaultPolicyVersion' ) AND eventsource = 'iam.amazonaws.com' ORDER BY eventtime
Name: ams_resource_events_query_v1 Description: >- The query provides list of events done on specific resource. The query accepts resource id as part of the filters, and return all write actions done on that resource. By default; the query list the accesses for last day, the user can change the time range by changing the datetime filter. AthenaQueryString: |- /* The query provides list of events done on specific resource. The query accepts the resource ID as part of the filters (replace the placeholder "<RESOURCE_INFO>" in the WHERE clause of the query), and returns all write actions done on that resource. The resource ID can be an ID for any AWS resource in the account. Example: An instance ID for an EC2 instance, table name for a DynamoDB table, logGroupName for a CloudWatch Log, etc. By default, the query filters the last day's events only; you can change the "datetime" filter to search for a wider time range. For expected inputs and scenarios, refer to AMS Documentation -> Tracking changes in your AMS Accelerate accounts -> Default Queries */ SELECT useridentity.principalId AS "IAM PrincipalId", useridentity.accesskeyid AS "IAM SessionId", useridentity.accountid AS "AccountId", reverse(split_part(reverse(useridentity.arn), ':', 1)) AS "ActionedBy", eventname AS "EventName", awsregion AS "EventRegion", eventid AS "EventId", eventsource AS "EventService", eventtime AS "EventTime" FROM "{DATABASE NAME HERE}".{TABLENAME HERE} <- This should auto-populate WHERE datetime > date_format(date_add('day', - 1, CURRENT_DATE), '%Y/%m/%d') AND readonly <> 'true' AND ( requestparameters LIKE '%<RESOURCE_INFO>%' OR responseelements LIKE '%<RESOURCE_INFO>%' ) ORDER BY eventtime InsightsQueryString: |- # The query provides list of events done on specific resource. # # The query accepts the resource ID as part of the filters (replace the placeholder "<RESOURCE_INFO>" in the filter of the query), # and returns all write actions done on that resource. The resource ID can be an ID for any AWS resource in the account. # Example: An instance ID for an EC2 instance, table name for a DynamoDB table, logGroupName for a CloudWatch Log, etc. # # For expected inputs and scenarios, refer to AMS Documentation -> Tracking changes in your AMS Accelerate accounts -> Default Queries filter readOnly=0 | parse @message '"requestParameters":{*}' as RequestParameters | parse @message '"responseElements":{*}' as ResponseElements # | filter RequestParameters like "RESOURCE_INFO" or ResponseElements like "<RESOURCE_INFO>" | fields userIdentity.principalId as IAMPrincipalId, userIdentity.accessKeyId as IAMSessionId, userIdentity.accountId as AccountId, userIdentity.arn as ActionedBy, eventName as EventName, awsRegion as EventRegion, eventID as EventId, eventSource as EventService, eventTime as EventTime | display IAMPrincipalId, IAMSessionId, AccountId, ActionedBy, EventName, EventRegion, EventId, EventService, EventTime | sort eventTime desc
Name: ams_session_events_query_v1 Description: >- The query provides list of events done on specific session. The query accepts IAM Principal Id as part of the filters, and return all write actions done on that resource. By default; the query list the accesses for last day, the user can change the time range by changing the datetime filter. AthenaQueryString: |- /* The query provides a list of events executed on a specific session. The query accepts the IAM principal ID as part of the filters (replace the placeholder "<PRINCIPAL_ID>" in the WHERE clause of the query), and returns all write actions done on that resource. By default, the query filters the last day's events only; you can change the "datetime" filter to search for a wider time range. For expected inputs and scenarios, refer to AMS Documentation -> Tracking changes in your AMS Accelerate accounts -> Default Queries */ SELECT useridentity.principalId AS "IAM PrincipalId", useridentity.accesskeyid AS "IAM SessionId", useridentity.accountid AS "AccountId", reverse(split_part(reverse(useridentity.arn), ':', 1)) AS "ActionedBy", eventname AS "EventName", awsregion AS "EventRegion", eventsource AS "EventService", eventtime AS "EventTime", requestparameters As "RequestParameters", responseelements AS "ResponseElements", useragent AS "UserAgent" FROM "{DATABASE NAME HERE}".{TABLENAME HERE} <- This should auto-populate WHERE useridentity.principalid = '<PRINCIPAL_ID>' AND datetime > date_format(date_add('day', - 1, CURRENT_DATE), '%Y/%m/%d') AND readonly <> 'true' ORDER BY eventtime InsightsQueryString: |- # The query provides a list of events executed on a specific session. # # The query accepts the IAM principal ID as part of the filters (replace the placeholder "<PRINCIPAL_ID>" in the filter of the query), # and returns all write actions done on that resource. # # For expected inputs and scenarios, refer to AMS Documentation -> Tracking changes in your AMS Accelerate accounts -> Default Queries filter readOnly=0 AND userIdentity.principalId = "<IAM Principal>" | sort eventTime desc | fields userIdentity.accessKeyId as IAMSessionId, userIdentity.principalId as IAMPrincipalId, userIdentity.accountId as AccountId, userIdentity.arn as ActionedBy, eventName as EventName, awsRegion as EventRegion, eventSource as EventService, eventTime as EventTime, userAgent as UserAgent | parse @message '"requestParameters":{*}' as RequestParameters | parse @message '"responseElements":{*}' as ResponseElements
Name: ams_session_ids_by_requester_v1 Description: >- The query provides list of IAM Principal/Session Ids for specific requester. The query accepts requester and return all IAM Principal/Session Ids by that requester during specific time range. By default; the query list the accesses for last day, the user can change the time range by changing the datetime filter. AthenaQueryString: |- /* The query provides list of IAM Principal IDs for a specific requester. The query accepts the requester (replace placeholder "<Requester>" in the WHERE clause of the query), and returns all IAM Principal IDs by that requester during a specific time range. By default, the query filters the last day's events only; you can change the "datetime" filter to search for a wider time range. For expected inputs and scenarios, refer to AMS Documentation -> Tracking changes in your AMS Accelerate accounts -> Default Queries */ SELECT json_extract_scalar(responseelements, '$.assumedRoleUser.assumedRoleId') AS "IAM PrincipalId", json_extract_scalar(responseelements, '$.credentials.accessKeyId') AS "IAM SessionIId", eventtime AS "EventTime" FROM "{DATABASE NAME HERE}".{TABLENAME HERE} <- This should auto-populate WHERE datetime > date_format(date_add('day', - 1, CURRENT_DATE), '%Y/%m/%d') AND json_extract_scalar(requestparameters, '$.tags[2].value') = '<Requester>' ORDER BY eventtime InsightsQueryString: |- # The query provides list of IAM Principal IDs for a specific requester. # # The query accepts the requester (replace placeholder "<Requester>" in the filter of the query), # and returns all IAM Principal IDs by that requester during a specific time range. # # For expected inputs and scenarios, refer to AMS Documentation -> Tracking changes in your AMS Accelerate accounts -> Default Queries filter eventName="AssumeRole" AND requestParameters.tags.2.value="<Requester>" | sort eventTime desc | fields responseElements.assumedRoleUser.assumedRoleId as IAMPrincipalId, responseElements.credentials.accessKeyId as IAMSessionId, eventTime as EventTime

レコードのアクセス許可を変更する

変更レコードクエリを実行するには、次のアクセス許可が必要です。

  • Athena

    • athena:GetWorkGroup

    • athena:StartQueryExecution

    • athena:ListDataCatalogs

    • athena:GetQueryExecution

    • athena:GetQueryResults

    • athena:BatchGetNamedQuery

    • athena:ListWorkGroups

    • athena:UpdateWorkGroup

    • athena:GetNamedQuery

    • athena:ListQueryExecutions

    • athena:ListNamedQueries

  • AWS KMS

    • kms:Decrypt

    • AWS KMS Accelerate が SSE-KMS 暗号化を使用して CloudTrail AMSCloudTrailLogManagement の AWS KMS キー ID、またはキー ID (複数可)。 Amazon S3

  • AWS Glue

    • glue:GetDatabase

    • glue:GetTables

    • glue:GetDatabases

    • glue:GetTable

  • Amazon S3 の読み取りアクセス

    • Amazon S3 バケット CloudTrail データストア: ams-aAccountId-cloudtrail-primary region、または Amazon S3 バケット名、CloudTrail 証跡イベント Amazon S3 バケットデータストア。

  • Amazon S3 書き込みアクセス

    • Athena イベントクエリ結果 Amazon S3 バケット: ams-aAccountId athena-results-primary region