View a markdown version of this page

Use DescribeTrails with a CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use DescribeTrails with a CLI

The following code examples show how to use DescribeTrails.

CLI
AWS CLI

To describe a trail

The following describe-trails example returns the settings for Trail1 and Trail2.

aws cloudtrail describe-trails \ --trail-name-list Trail1 Trail2

Output:

{ "trailList": [ { "IncludeGlobalServiceEvents": true, "Name": "Trail1", "TrailARN": "arn:aws:cloudtrail:us-west-2:123456789012:trail/Trail1", "LogFileValidationEnabled": false, "IsMultiRegionTrail": false, "S3BucketName": "amzn-s3-demo-bucket", "CloudWatchLogsRoleArn": "arn:aws:iam::123456789012:role/CloudTrail_CloudWatchLogs_Role", "CloudWatchLogsLogGroupArn": "arn:aws:logs:us-west-2:123456789012:log-group:CloudTrail:*", "SnsTopicName": "my-topic", "HomeRegion": "us-west-2" }, { "IncludeGlobalServiceEvents": true, "Name": "Trail2", "S3KeyPrefix": "my-prefix", "TrailARN": "arn:aws:cloudtrail:us-west-2:123456789012:trail/Trail2", "LogFileValidationEnabled": false, "IsMultiRegionTrail": false, "S3BucketName": "amzn-s3-demo-bucket2", "KmsKeyId": "arn:aws:kms:us-west-2:123456789012:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "HomeRegion": "us-west-2" } ] }

For more information, see Managing trails with the AWS CLI in the AWS CloudTrail User Guide.

PowerShell
Tools for PowerShell V4

Example 1: Returns the settings of all trails associated with the current region for your account.

Get-CTTrail

Example 2: Returns the settings for the specified trails.

Get-CTTrail -TrailNameList trail1,trail2

Example 3: Returns the settings for the specified trails that were created in a region other than the current shell default (in this case the Frankfurt (eu-central-1) region).

Get-CTTrail -TrailNameList trailABC,trailDEF -Region eu-central-1
  • For API details, see DescribeTrails in AWS Tools for PowerShell Cmdlet Reference (V4).

Tools for PowerShell V5

Example 1: Returns the settings of all trails associated with the current region for your account.

Get-CTTrail

Example 2: Returns the settings for the specified trails.

Get-CTTrail -TrailNameList trail1,trail2

Example 3: Returns the settings for the specified trails that were created in a region other than the current shell default (in this case the Frankfurt (eu-central-1) region).

Get-CTTrail -TrailNameList trailABC,trailDEF -Region eu-central-1
  • For API details, see DescribeTrails in AWS Tools for PowerShell Cmdlet Reference (V5).