Log API calls with AWS CloudTrail - AWS Fault Injection Service

Log API calls with AWS CloudTrail

AWS Fault Injection Service (AWS FIS) is integrated with AWS CloudTrail, a service that provides a record of actions taken by a user, a role, or an AWS service in AWS FIS. CloudTrail captures all API calls for AWS FIS as events. The calls that are captured include calls from the AWS FIS console and code calls to the AWS FIS API operations. If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon S3 bucket, including events for AWS FIS. 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 AWS FIS, 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.

Use CloudTrail

CloudTrail is enabled on your AWS account when you create the account. When activity occurs in AWS FIS, that activity is recorded in a CloudTrail event along 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 AWS FIS, 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 upon the event data collected in CloudTrail logs. For more information, see the following:

All AWS FIS actions are logged by CloudTrail and are documented in the AWS Fault Injection Service API Reference. For the experiment actions that are carried out on a target resource, view the API reference documentation for the service that owns the resource. For example, for actions that are carried out on an Amazon EC2 instance, see the Amazon EC2 API Reference.

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.

Understand AWS FIS 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 aren't an ordered stack trace of the public API calls, so they don't appear in any specific order.

The following is an example CloudTrail log entry for a call to the AWS FIS StopExperiment action.

{ "eventVersion": "1.08", "userIdentity": { "type": "AssumedRole", "principalId": "AKIAIOSFODNN7EXAMPLE:jdoe", "arn": "arn:aws:sts::111122223333:assumed-role/example/jdoe", "accountId": "111122223333", "accessKeyId": "AKIAI44QH8DHBEXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "AKIAIOSFODNN7EXAMPLE", "arn": "arn:aws:iam::111122223333:role/example", "accountId": "111122223333", "userName": "example" }, "webIdFederationData": {}, "attributes": { "creationDate": "2020-12-03T09:40:42Z", "mfaAuthenticated": "false" } } }, "eventTime": "2020-12-03T09:44:20Z", "eventSource": "fis.amazonaws.com", "eventName": "StopExperiment", "awsRegion": "us-east-1", "sourceIPAddress": "192.51.100.25", "userAgent": "Boto3/1.22.9 Python/3.8.13 Linux/5.4.186-113.361.amzn2int.x86_64 Botocore/1.25.9", "requestParameters": { "clientToken": "1234abc5-6def-789g-012h-ijklm34no56p", "experimentTemplateId": "ABCDE1fgHIJkLmNop", "tags": {} }, "responseElements": { "experiment": { "actions": { "exampleAction1": { "actionId": "aws:ec2:stop-instances", "duration": "PT10M", "state": { "reason": "Initial state", "status": "pending" }, "targets": { "Instances": "exampleTag1" } }, "exampleAction2": { "actionId": "aws:ec2:stop-instances", "duration": "PT10M", "state": { "reason": "Initial state", "status": "pending" }, "targets": { "Instances": "exampleTag2" } } }, "creationTime": 1605788649.95, "endTime": 1606988660.846, "experimentTemplateId": "ABCDE1fgHIJkLmNop", "id": "ABCDE1fgHIJkLmNop", "roleArn": "arn:aws:iam::111122223333:role/AllowFISActions", "startTime": 1605788650.109, "state": { "reason": "Experiment stopped", "status": "stopping" }, "stopConditions": [ { "source": "aws:cloudwatch:alarm", "value": "arn:aws:cloudwatch:us-east-1:111122223333:alarm:example" } ], "tags": {}, "targets": { "ExampleTag1": { "resourceTags": { "Example": "tag1" }, "resourceType": "aws:ec2:instance", "selectionMode": "RANDOM(1)" }, "ExampleTag2": { "resourceTags": { "Example": "tag2" }, "resourceType": "aws:ec2:instance", "selectionMode": "RANDOM(1)" } } } }, "requestID": "1abcd23e-f4gh-567j-klm8-9np01q234r56", "eventID": "1234a56b-c78d-9e0f-g1h2-34jk56m7n890", "readOnly": false, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "111122223333", "eventCategory": "Management" }

The following is an example CloudTrail log entry for an API action that AWS FIS invoked as part of an experiment that includes the aws:ssm:send-command AWS FIS action. The userIdentity element reflects a request made with temporary credentials obtained by assuming a role. The name of the assumed role appears in userName. The ID of the experiment, EXP21nT17WMzA6dnUgz, appears in principalId and as part of the ARN of the assumed role.

{ "eventVersion": "1.08", "userIdentity": { "type": "AssumedRole", "principalId": "AROATZZZ4JPIXUEXAMPLE:EXP21nT17WMzA6dnUgz", "arn": "arn:aws:sts::111122223333:assumed-role/AllowActions/EXP21nT17WMzA6dnUgz", "accountId": "111122223333", "accessKeyId": "AKIAI44QH8DHBEXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "AROATZZZ4JPIXUEXAMPLE", "arn": "arn:aws:iam::111122223333:role/AllowActions", "accountId": "111122223333", "userName": "AllowActions" }, "webIdFederationData": {}, "attributes": { "creationDate": "2022-05-30T13:23:19Z", "mfaAuthenticated": "false" } }, "invokedBy": "fis.amazonaws.com" }, "eventTime": "2022-05-30T13:23:19Z", "eventSource": "ssm.amazonaws.com", "eventName": "ListCommands", "awsRegion": "us-east-2", "sourceIPAddress": "fis.amazonaws.com", "userAgent": "fis.amazonaws.com", "requestParameters": { "commandId": "51dab97f-489b-41a8-a8a9-c9854955dc65" }, "responseElements": null, "requestID": "23709ced-c19e-471a-9d95-cf1a06b50ee6", "eventID": "145fe5a6-e9d5-45cc-be25-b7923b950c83", "readOnly": true, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "111122223333", "eventCategory": "Management" }