Logging Step Functions Using AWS CloudTrail - AWS Step Functions

Logging Step Functions Using AWS CloudTrail

Step Functions is integrated with AWS CloudTrail, a service that provides a record of actions taken by a user, role, or an AWS service in Step Functions. CloudTrail captures all API calls for Step Functions as events, including calls from the Step Functions console and from code calls to the Step Functions APIs.

If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon Simple Storage Service (Amazon S3) bucket, including events for Step Functions. If you don't configure a trail, you can still view the most recent events in the CloudTrail console in Event history.

Using the information collected by CloudTrail, you can determine the request that was made to Step Functions, the IP address from which the request was made, who made the request, when it was made, and additional details.

To learn more about CloudTrail, see the AWS CloudTrail User Guide.

Step Functions Information in CloudTrail

CloudTrail is enabled on your AWS account when you create the account. When activity occurs in Step Functions, that activity is recorded in a CloudTrail event with other AWS service events in Event history.

You can view, search, and download recent events in your AWS account. For more information, see Viewing Events with CloudTrail Event History.

For an ongoing record of events in your AWS account, including events for Step Functions, create a trail. A trail enables CloudTrail to deliver log files to an Amazon S3 bucket. By default, when you create a trail in the console, the trail applies to all AWS Regions. The trail logs events from all Regions in the AWS partition and delivers the log files to the Amazon S3 bucket that you specify. Additionally, you can configure other AWS services to further analyze and act on the event data collected in CloudTrail logs.

For more information, see the following:

Every event or log entry contains information about who generated the request. The identity information helps you determine the following:

  • Whether the request was made with root or user credentials

  • Whether the request was made with temporary security credentials for a role or federated user

  • Whether the request was made by another AWS service

For more information, see the CloudTrail userIdentity Element.

Example: Step Functions Log File Entries

A trail is a configuration that enables delivery of events as log files to an Amazon S3 bucket that you specify. CloudTrail log files contain one or more log entries. An event represents a single request from any source and includes information about the requested action, the date and time of the action, request parameters, and so on. CloudTrail log files are not an ordered stack trace of the public API calls, so they don't appear in any specific order.

CreateActivity

The following example shows a CloudTrail log entry that demonstrates the CreateActivity action.

{ "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

The following example shows a CloudTrail log entry that demonstrates the CreateStateMachine action.

{ "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

The following example shows a CloudTrail log entry that demonstrates the DeleteActivity action.

{ "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

The following example shows a CloudTrail log entry that demonstrates the DeleteStateMachine action.

{ "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

The following example shows a CloudTrail log entry that demonstrates the StartExecution action.

{ "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

The following example shows a CloudTrail log entry that demonstrates the StopExecution action.

{ "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" }