AWS CloudTrail を使用した AWS CodeStar Notifications API コールのログ記録 - デベロッパーツールコンソール

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

AWS CloudTrail を使用した AWS CodeStar Notifications API コールのログ記録

AWS CodeStar Notifications は、ユーザー、ロール、または AWS のサービスによって実行されるアクションを記録するサービス AWS CloudTrail と統合されています。CloudTrail は、 のすべての API コールをイベントとしてキャプチャします。キャプチャされた呼び出しには、デベロッパーツールコンソールからの呼び出しと、AWS CodeStar Notifications API オペレーションへのコードの呼び出しが含まれます。証跡を作成する場合は、通知のイベントなど、Amazon S3 バケットへの CloudTrail イベントの継続的な配信を有効にすることができます 追跡を設定しない場合でも、CloudTrail コンソールの [Event history] (イベント履歴) で最新のイベントを表示できます。CloudTrail で収集された情報を使用して、AWS CodeStar Notifications に対するリクエスト、リクエスト元の IP アドレス、リクエスト者、リクエスト日時などの詳細を確認できます。

詳細については、AWS CloudTrailユーザーガイドを参照してください。

CloudTrail での AWS CodeStar Notifications 情報

CloudTrail は、アカウント作成時に AWS アカウント で有効になります。AWS CodeStar Notifications でアクティビティが発生すると、そのアクティビティは [Event history] (イベント履歴) の他の AWS サービスイベントと共に CloudTrail イベントに記録されます。最近のイベントは、AWS アカウント で表示、検索、ダウンロードできます。詳細については、「Viewing events with CloudTrail event history」(CloudTrail イベント履歴でのイベントの表示) を参照してください。

AWS CodeStar Notifications のイベントを含む、AWS アカウント のイベントの継続的な記録については、証跡を作成します。追跡により、CloudTrail はログファイルを Amazon S3 バケットに配信できます。デフォルトでは、コンソールで証跡を作成するときに、証跡がすべての AWS リージョン に適用されます 証跡は、AWS パーティションのすべてのリージョンからのイベントをログに記録し、指定した Amazon S3 バケットにログファイルを配信します。さらに、CloudTrail・ログで収集したイベントデータをより詳細に分析し、それに基づく対応するためにその他の AWS のサービスを設定できます。詳細については、次を参照してください。

すべての AWS CodeStar Notifications アクションは CloudTrail が記録します。これらのアクションは「AWS CodeStar Notifications API Reference」(AWS CodeStar Notifications API リファレンス) で説明されています。例えば、CreateNotificationRuleSubscribeListEventTypesの各アクションを呼び出すと、CloudTrail ログファイルにエントリが生成されます。

各イベントまたはログエントリには、誰がリクエストを生成したかという情報が含まれます。アイデンティティ情報は、以下を判別するのに役立ちます。

  • リクエストが、ルート認証情報と AWS Identity and Access Management (IAM) ユーザー認証情報のどちらを使用して送信されたか.

  • リクエストがロールまたはフェデレーティッドユーザーのテンポラリなセキュリティ認証情報を使用して行われたかどうか。

  • リクエストが、別の AWS のサービスによって送信されたかどうか。

詳細については、「CloudTrail userIdentity 要素」 をご参照ください。

ログファイルエントリの理解

追跡は、指定した Amazon S3 バケットにイベントをログファイルとして配信するように設定できます。CloudTrail のログファイルには、単一か複数のログエントリがあります。イベントはあらゆるソースからの単一のリクエストを表し、リクエストされたアクション、アクションの日時、リクエストのパラメータなどの情報が含まれます。CloudTrail ログファイルは、パブリック API コールの順序付けられたスタックトレースではないため、特定の順序では表示されません。

次の例は、CreateNotificationRule アクションと Subscribe アクションの両方を含む通知ルールの作成を示す CloudTrail ログエントリを示しています。

注記

通知ログファイルエントリの一部のイベントは、サービスにリンクされたロール AWSServiceRoleForCodeStarNotifications から送信される場合があります。

{ "eventVersion": "1.05", "userIdentity": { "type":"IAMUser", "principalId":"AIDACKCEVSQ6C2EXAMPLE", "arn":"arn:aws:iam::123456789012:user/Mary_Major", "accountId":"123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName":"Mary_Major" }, "eventTime": "2019-10-07T21:34:41Z", "eventSource": "events.amazonaws.com", "eventName": "CreateNotificationRule", "awsRegion": "us-east-1", "sourceIPAddress": "codestar-notifications.amazonaws.com", "userAgent": "codestar-notifications.amazonaws.com", "requestParameters": { "description": "This rule is used to route CodeBuild, CodeCommit, CodePipeline, and other Developer Tools notifications to AWS CodeStar Notifications", "name": "awscodestarnotifications-rule", "eventPattern": "{\"source\":[\"aws.codebuild\",\"aws.codecommit\",\"aws.codepipeline\"]}" }, "responseElements": { "ruleArn": "arn:aws:events:us-east-1:123456789012:rule/awscodestarnotifications-rule" }, "requestID": "ff1f309a-EXAMPLE", "eventID": "93c82b07-EXAMPLE", "eventType": "AwsApiCall", "apiVersion": "2015-10-07", "recipientAccountId": "123456789012" }
{ "eventVersion": "1.05", "userIdentity": { "type":"IAMUser", "principalId":"AIDACKCEVSQ6C2EXAMPLE", "arn":"arn:aws:iam::123456789012:user/Mary_Major", "accountId":"123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName":"Mary_Major" }, "eventTime": "2019-10-07T21:34:41Z", "eventSource": "events.amazonaws.com", "eventName": "Subscribe", "awsRegion": "us-east-1", "sourceIPAddress": "codestar-notifications.amazonaws.com", "userAgent": "codestar-notifications.amazonaws.com", "requestParameters": { "targets": [ { "arn": "arn:aws:codestar-notifications:us-east-1:::", "id": "codestar-notifications-events-target" } ], "rule": "awscodestarnotifications-rule" }, "responseElements": { "failedEntryCount": 0, "failedEntries": [] }, "requestID": "9466cbda-EXAMPLE", "eventID": "2f79fdad-EXAMPLE", "eventType": "AwsApiCall", "apiVersion": "2015-10-07", "recipientAccountId": "123456789012" }