Listing the CloudTrail Trails - AWS SDK for Ruby

Listing the CloudTrail Trails

This example uses the describe_trails method to list the names of the CloudTrail trails and the bucket in which CloudTrail stores information in the us-west-2 region.

Choose Copy to save the code locally.

Create the file describe_trails.rb with the following code.

=begin ############################################################################### Purpose: Lists information about a trail in AWS CloudTrail. Prerequisites: - You must have an AWS account. For more information, see "How do I create and activate a new Amazon Web Services account" on the AWS Premium Support website. - This code uses default AWS access credentials. For more information, see "Configuring the AWS SDK for Ruby" in the AWS SDK for Ruby Developer Guide. Running the code: To run this code, use RSpec. For example: rspec aws-ruby-sdk-cloudtrail-example-describe-trails.rb -f d Additional information: - As an AWS best practice, grant this code least privilege, or only the permissions required to perform a task. For more information, see "Grant Least Privilege," in the AWS Identity and Access Management User Guide. - This code has not been tested in all AWS Regions. Some AWS services are available only in specific Regions. For more information, see the "AWS Regional Table" on the AWS website. - Running this code outside of the included RSpec tests might result in charges to your AWS account.

See the complete example on GitHub.