Logging Amazon Systems Manager API calls with Amazon CloudTrail - Amazon Systems Manager
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Logging Amazon Systems Manager API calls with Amazon CloudTrail

Amazon Systems Manager is integrated with Amazon CloudTrail, a service that provides a record of actions taken by a user, role, or an Amazon Web Service in Systems Manager. CloudTrail captures Systems Manager API calls as events, including calls initiated from the Systems Manager console and calls made to the Systems Manager APIs. If you create a trail, you can turn on continual delivery of CloudTrail events to an S3 bucket, including events for Systems Manager. 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 Systems Manager, 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 Amazon CloudTrail User Guide.

Systems Manager information in CloudTrail

CloudTrail is activated on your Amazon Web Services account when you create the account. When activity occurs in Systems Manager, that activity is recorded in a CloudTrail event along with other Amazon Web Service events in Event history. You can view, search, and download recent events in your Amazon Web Services account. For more information, see Viewing events with CloudTrail Event history in the Amazon CloudTrail User Guide.

For an ongoing record of events in your Amazon Web Services account, including events for Systems Manager, create a trail. A trail allows CloudTrail to deliver log files to an S3 bucket. By default, when you create a trail in the console, the trail applies to all Amazon Web Services Regions. The trail logs events from all Regions in the Amazon partition and delivers the log files to the S3 bucket that you specify. Additionally, you can configure other Amazon Web Services to further analyze and act upon the event data collected in CloudTrail logs. For more information, see:

Most Systems Manager API operations are logged by CloudTrail and are documented in the Amazon Systems Manager API Reference. For example, calls to the CreateMaintenanceWindows, PutInventory, SendCommand, and StartSession actions generate entries in the CloudTrail log files. For an example of setting up CloudTrail to monitor a Systems Manager API call, see Monitoring session activity using Amazon EventBridge (console) .

Every event or log entry contains information that helps you determine who made the request.

  • Amazon Web Services account root user

  • Temporary security credentials from an Amazon Identity and Access Management (IAM) role or federated user.

  • Long-term security credentials from an IAM user.

  • Another Amazon service.

For more information, see the CloudTrail userIdentity Element.

Understanding Systems Manager log file entries

A trail is a configuration that allows delivery of events as log files to an 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 operation, the date and time of the operation, request parameters, and so on. CloudTrail log files aren't an ordered stack trace of the public API calls, so they aren't displayed in any specific order.

Example 1: DeleteDocument

The following example shows a CloudTrail log entry that demonstrates the DeleteDocument operation on a document named example-Document in the US East (Ohio) Region (us-east-2).

{ "eventVersion": "1.04", "userIdentity": { "type": "AssumedRole", "principalId": "AKIAI44QH8DHBEXAMPLE:", "arn": "arn:aws-cn:sts::123456789012:assumed-role/example-role/", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2018-03-06T20:19:16Z" }, "sessionIssuer": { "type": "Role", "principalId": "AKIAI44QH8DHBEXAMPLE", "arn": "arn:aws-cn:iam::123456789012:role/example-role", "accountId": "123456789012", "userName": "example-role" } } }, "eventTime": "2018-03-06T20:30:12Z", "eventSource": "ssm.amazonaws.com", "eventName": "DeleteDocument", "awsRegion": "us-east-2", "sourceIPAddress": "", "userAgent": "example-user-agent-string", "requestParameters": { "name": "example-Document" }, "responseElements": null, "requestID": "86168559-75e9-11e4-8cf8-75d18EXAMPLE", "eventID": "832b82d5-d474-44e8-a51d-093ccEXAMPLE", "resources": [ { "ARN": "arn:aws:ssm:us-east-2:123456789012:document/example-Document", "accountId": "123456789012" } ], "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }
Example 2: StartConnection

The following example shows a CloudTrail log entry for a user who starts an RDP connection using Fleet Manager in the US East (Ohio) Region (us-east-2). The underlying API action is StartConnection.

{ "eventVersion": "1.08", "userIdentity": { "type": "AssumedRole", "principalId": "AKIAI44QH8DHBEXAMPLE", "arn": "arn:aws-cn:sts::123456789012:assumed-role/exampleRole", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "AKIAI44QH8DHBEXAMPLE", "arn": "arn:aws-cn:sts::123456789012:assumed-role/exampleRole", "accountId": "123456789012", "userName": "exampleRole" }, "webIdFederationData": {}, "attributes": { "creationDate": "2021-12-13T14:57:05Z", "mfaAuthenticated": "false" } } }, "eventTime": "2021-12-13T16:50:41Z", "eventSource": "ssm-guiconnect.amazonaws.com", "eventName": "StartConnection", "awsRegion": "us-east-2", "sourceIPAddress": "", "userAgent": "example-user-agent-string", "requestParameters": { "AuthType": "Credentials", "Protocol": "RDP", "ConnectionType": "SessionManager", "InstanceId": "i-02573cafcfEXAMPLE" }, "responseElements": { "ConnectionArn": "arn:aws:ssm-guiconnect:us-east-2:123456789012:connection/fcb810cd-241f-4aae-9ee4-02d59EXAMPLE", "ConnectionKey": "71f9629f-0f9a-4b35-92f2-2d253EXAMPLE", "ClientToken": "49af0f92-d637-4d47-9c54-ea51aEXAMPLE", "requestId": "d466710f-2adf-4e87-9464-055b2EXAMPLE" }, "requestID": "d466710f-2adf-4e87-9464-055b2EXAMPLE", "eventID": "fc514f57-ba19-4e8b-9079-c2913EXAMPLE", "readOnly": false, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "123456789012", "eventCategory": "Management" }