Logging Amazon Inspector API calls using AWS CloudTrail
Amazon Inspector is integrated with AWS CloudTrail, a service that provides a record of actions taken by an IAM user or role, or an AWS service, in Amazon Inspector. CloudTrail captures all API calls for Amazon Inspector as events. The calls captured include calls from the Amazon Inspector console and calls to the Amazon Inspector API operations. If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon S3 bucket, including events for Amazon Inspector. 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 Amazon Inspector.
-
The IP address from which the request was made.
-
Who made the request.
-
When the request was made.
To learn more about CloudTrail, see the AWS CloudTrail User Guide.
Amazon Inspector information in CloudTrail
CloudTrail is enabled on your AWS account when you create the account. When activity occurs in Amazon Inspector, 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 Amazon Inspector, 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 topics:
All Amazon Inspector actions are logged by CloudTrail. All actions that Amazon Inspector can make are
documented in the Amazon Inspector API Reference. For example, calls to the
CreateFindingsReport
, ListCoverage
, and
UpdateOrganizationConfiguration
actions generate entries in the
CloudTrail log files.
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 user or IAM user credentials.
-
Whether the request was made with temporary security credentials for a role or a federated user.
-
Whether the request was made by another AWS service.
For more information, see the CloudTrail userIdentity element.
Understanding Amazon Inspector 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. Events include 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.
Amazon Inspector Scan information in CloudTrail
Amazon Inspector Scan is integrated with CloudTrail. All Amazon Inspector Scan API operations are logged as management events. For a list of the Amazon Inspector Scan API operations that Amazon Inspector logs to CloudTrail, see Amazon Inspector Scan in the Amazon Inspector API Reference.
The following example shows a CloudTrail log entry that demonstrates the ScanSbom
action:
{ "eventVersion": "1.08", "userIdentity": { "type": "AssumedRole", "principalId": "AROA123456789EXAMPLE:akua_mansa", "arn": "arn:aws:sts::111122223333:assumed-role/Admin/akua_mansa", "accountId": "111122223333", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "AROA123456789EXAMPLE", "arn": "arn:aws:iam::111122223333:role/Admin", "accountId": "111122223333", "userName": "Admin" }, "webIdFederationData": {}, "attributes": { "creationDate": "2023-10-17T15:22:59Z", "mfaAuthenticated": "false" } } }, "eventTime": "2023-10-17T16:02:34Z", "eventSource": "gamma-inspector-scan.amazonaws.com", "eventName": "ScanSbom", "awsRegion": "us-east-1", "sourceIPAddress": "203.0.113.0", "userAgent": "aws-sdk-java/2.20.162 Mac_OS_X/13.5.2 OpenJDK_64-Bit_Server_VM/17.0.8+7-LTS Java/17.0.8 vendor/Amazon.com_Inc. io/sync http/UrlConnection cfg/retry-mode/legacy", "requestParameters": { "sbom": { "specVersion": "1.5", "metadata": { "component": { "name": "debian", "type": "operating-system", "version": "9" } }, "components": [ { "name": "packageOne", "purl": "pkg:deb/debian/packageOne@1.0.0?arch=x86_64&distro=9", "type": "application" } ], "bomFormat": "CycloneDX" } }, "responseElements": null, "requestID": "f041a27f-f33e-4f70-b09b-5fbc5927282a", "eventID": "abc8d1e4-d214-4f07-bc56-8a31be6e36fe", "readOnly": true, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "111122223333", "eventCategory": "Management" }