AWS CloudTrail を使用して Step Functions をログ記録 - AWS Step Functions

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

AWS CloudTrail を使用して Step Functions をログ記録

Step Functions は、Step Functions 内のユーザー、ロールまたは AWS のサービスによって実行されたアクションのレコードを提供するサービスである AWS CloudTrail と統合されています。CloudTrail は、 Step Functions コンソールからのコールとコードコールから Step Functions API へのコールなど、Step Functions の API コールをイベントとしてキャプチャします。 

追跡を作成する場合は、Step Functions のイベントなど、Amazon Simple Storage Service (Amazon S3) バケットへの CloudTrail イベントの継続的な配信を有効にすることができます。証跡を設定しない場合でも、CloudTrail コンソールの [Event history] (イベント履歴) で最新のイベントを表示できます。

CloudTrail で収集された情報を使用して、Step Functions に対するリクエスト、リクエスタの IP アドレス、リクエスト者、リクエスト日時などの追加詳細を確認できます。

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

CloudTrail における Step Functions 情報

AWS アカウントを作成すると、そのアカウントに対して CloudTrail が有効になります。Step Functions でアクティビティが発生すると、そのアクティビティは、[Event history] (イベント履歴) にある他の AWS のサービスとともに、 CloudTrail イベントに記録されます。

最近のイベントは、AWS アカウントで表示、検索、ダウンロードできます。詳細については、CloudTrail イベント履歴でのイベントの表示を参照してください。

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

詳細については、次を参照してください。

各イベントまたはログエントリには、リクエストの生成者に関する情報が含まれます。同一性情報は次の判断に役立ちます。

  • リクエストが、ルートと ユーザー認証情報のどちらを使用して送信されたか

  • リクエストが、ロールとフェデレーティッドユーザーのどちらの一時的なセキュリティ認証情報を使用して送信されたか

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

詳細については、CloudTrail userIdentity エレメントを参照してください。

例:Step Functions ログファイルエントリ

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

CreateActivity

次の例は、CreateActivity アクションを示す CloudTrail ログエントリです。

{ "eventVersion": "1.04", "userIdentity": { "type": "IAMUser", "principalId": "AIDAJYDLDBVBI4EXAMPLE", "arn": "arn:aws:iam::123456789012:user/test-user", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "test-user" }, "eventTime": "2016-10-28T01:17:56Z", "eventSource": "states.amazonaws.com", "eventName": "CreateActivity", "awsRegion": "us-east-1", "sourceIPAddress": "AWS Internal", "userAgent": "AWS Internal", "requestParameters": { "name": "OtherActivityPrefix.2016-10-27-18-16-56.894c791e-2ced-4cf4-8523-376469410c25" }, "responseElements": { "activityArn": "arn:aws:states:us-east-1:123456789012:activity:OtherActivityPrefix.2016-10-27-18-16-56.894c791e-2ced-4cf4-8523-376469410c25", "creationDate": "Oct 28, 2016 1:17:56 AM" }, "requestID": "37c67602-9cac-11e6-aed5-5b57d226e9ef", "eventID": "dc3becef-d06d-49bf-bc93-9b76b5f00774", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }

CreateStateMachine

次の例は、CreateStateMachine アクションを示す CloudTrail ログエントリです。

{ "eventVersion": "1.04", "userIdentity": { "type": "IAMUser", "principalId": "AIDAJYDLDBVBI4EXAMPLE", "arn": "arn:aws:iam::123456789012:user/test-user", "accountId": "123456789012", "accessKeyId": "AKIAJL5C75K4ZEXAMPLE", "userName": "test-user" }, "eventTime": "2016-10-28T01:18:07Z", "eventSource": "states.amazonaws.com", "eventName": "CreateStateMachine", "awsRegion": "us-east-1", "sourceIPAddress": "AWS Internal", "userAgent": "AWS Internal", "requestParameters": { "name": "testUser.2016-10-27-18-17-06.bd144e18-0437-476e-9bb", "roleArn": "arn:aws:iam::123456789012:role/graphene/tests/graphene-execution-role", "definition": "{ \"StartAt\": \"SinglePass\", \"States\": { \"SinglePass\": { \"Type\": \"Pass\", \"End\": true } }}" }, "responseElements": { "stateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:testUser.2016-10-27-18-17-06.bd144e18-0437-476e-9bb", "creationDate": "Oct 28, 2016 1:18:07 AM" }, "requestID": "3da6370c-9cac-11e6-aed5-5b57d226e9ef", "eventID": "84a0441d-fa06-4691-a60a-aab9e46d689c", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }

DeleteActivity

次の例は、DeleteActivity アクションを示す CloudTrail ログエントリです。

{ "eventVersion": "1.04", "userIdentity": { "type": "IAMUser", "principalId": "AIDAJYDLDBVBI4EXAMPLE", "arn": "arn:aws:iam::123456789012:user/test-user", "accountId": "123456789012", "accessKeyId": "AKIAJL5C75K4ZEXAMPLE", "userName": "test-user" }, "eventTime": "2016-10-28T01:18:27Z", "eventSource": "states.amazonaws.com", "eventName": "DeleteActivity", "awsRegion": "us-east-1", "sourceIPAddress": "AWS Internal", "userAgent": "AWS Internal", "requestParameters": { "activityArn": "arn:aws:states:us-east-1:123456789012:activity:testUser.2016-10-27-18-11-35.f017c391-9363-481a-be2e-" }, "responseElements": null, "requestID": "490374ea-9cac-11e6-aed5-5b57d226e9ef", "eventID": "e5eb9a3d-13bc-4fa1-9531-232d1914d263", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }

DeleteStateMachine

次の例は、DeleteStateMachine アクションを示す CloudTrail ログエントリです。

{ "eventVersion": "1.04", "userIdentity": { "type": "IAMUser", "principalId": "AIDAJABK5MNKNAEXAMPLE", "arn": "arn:aws:iam::123456789012:user/graphene/tests/test-user", "accountId": "123456789012", "accessKeyId": "AKIAJA2ELRVCPEXAMPLE", "userName": "test-user" }, "eventTime": "2016-10-28T01:17:37Z", "eventSource": "states.amazonaws.com", "eventName": "DeleteStateMachine", "awsRegion": "us-east-1", "sourceIPAddress": "AWS Internal", "userAgent": "AWS Internal", "errorCode": "AccessDenied", "errorMessage": "User: arn:aws:iam::123456789012:user/graphene/tests/test-user is not authorized to perform: states:DeleteStateMachine on resource: arn:aws:states:us-east-1:123456789012:stateMachine:testUser.2016-10-27-18-16-38.ec6e261f-1323-4555-9fa", "requestParameters": null, "responseElements": null, "requestID": "2cf23f3c-9cac-11e6-aed5-5b57d226e9ef", "eventID": "4a622d5c-e9cf-4051-90f2-4cdb69792cd8", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }

StartExecution

次の例は、StartExecution アクションを示す CloudTrail ログエントリです。

{ "eventVersion": "1.04", "userIdentity": { "type": "IAMUser", "principalId": "AIDAJYDLDBVBI4EXAMPLE", "arn": "arn:aws:iam::123456789012:user/test-user", "accountId": "123456789012", "accessKeyId": "AKIAJL5C75K4ZEXAMPLE", "userName": "test-user" }, "eventTime": "2016-10-28T01:17:25Z", "eventSource": "states.amazonaws.com", "eventName": "StartExecution", "awsRegion": "us-east-1", "sourceIPAddress": "AWS Internal", "userAgent": "AWS Internal", "requestParameters": { "input": "{}", "stateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:testUser.2016-10-27-18-16-26.482bea32-560f-4a36-bd", "name": "testUser.2016-10-27-18-16-26.6e229586-3698-4ce5-8d" }, "responseElements": { "startDate": "Oct 28, 2016 1:17:25 AM", "executionArn": "arn:aws:states:us-east-1:123456789012:execution:testUser.2016-10-27-18-16-26.482bea32-560f-4a36-bd:testUser.2016-10-27-18-16-26.6e229586-3698-4ce5-8d" }, "requestID": "264c6f08-9cac-11e6-aed5-5b57d226e9ef", "eventID": "30a20c8e-a3a1-4b07-9139-cd9cd73b5eb8", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }

StopExecution

次の例は、StopExecutionアクションを示す CloudTrail ログエントリです。

{ "eventVersion": "1.04", "userIdentity": { "type": "IAMUser", "principalId": "AIDAJYDLDBVBI4EXAMPLE", "arn": "arn:aws:iam::123456789012:user/test-user", "accountId": "123456789012", "accessKeyId": "AKIAJL5C75K4ZEXAMPLE", "userName": "test-user" }, "eventTime": "2016-10-28T01:18:20Z", "eventSource": "states.amazonaws.com", "eventName": "StopExecution", "awsRegion": "us-east-1", "sourceIPAddress": "AWS Internal", "userAgent": "AWS Internal", "requestParameters": { "executionArn": "arn:aws:states:us-east-1:123456789012:execution:testUser.2016-10-27-18-17-00.337b3344-83:testUser.2016-10-27-18-17-00.3a0801c5-37" }, "responseElements": { "stopDate": "Oct 28, 2016 1:18:20 AM" }, "requestID": "4567625b-9cac-11e6-aed5-5b57d226e9ef", "eventID": "e658c743-c537-459a-aea7-dafb83c18c53", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }