2018-01-23 16:26:27 +00:00
---
title: About the aws_cloudtrail_trail Resource
2018-02-13 19:30:07 +00:00
platform: aws
2018-01-23 16:26:27 +00:00
---
2018-02-15 02:23:29 +00:00
# aws\_cloudtrail\_trail
2018-01-23 16:26:27 +00:00
Use the `aws_cloudtrail_trail` InSpec audit resource to test properties of a single AWS Cloudtrail Trail.
AWS CloudTrail is a service that enables governance, compliance, operational auditing, and risk auditing of your AWS account. With CloudTrail, you can log, continuously monitor, and retain account activity related to actions across your AWS infrastructure. CloudTrail provides event history of your AWS account activity, including actions taken through the AWS Management Console, AWS SDKs, command line tools, and other AWS services. This event history simplifies security analysis, resource change tracking, and troubleshooting.
2018-02-15 02:23:29 +00:00
Each AWS Cloudtrail Trail is uniquely identified by its `trail_name` or `trail_arn`.
2018-01-23 16:26:27 +00:00
<br>
## Syntax
2018-02-15 02:23:29 +00:00
An `aws_cloudtrail_trail` resource block identifies a trail by `trail_name`.
2018-01-23 16:26:27 +00:00
# Find a trail by name
describe aws_cloudtrail_trail('trail-name') do
it { should exist }
end
# Hash syntax for trail name
describe aws_cloudtrail_trail(trail_name: 'trail-name') do
it { should exist }
end
<br>
2018-02-14 01:42:39 +00:00
## Examples
The following examples show how to use this InSpec audit resource.
### Test that the specified trail does exist
describe aws_cloudtrail_trail('trail-name') do
it { should exist }
end
### Test that the specified trail is encrypted using SSE-KMS
describe aws_cloudtrail_trail('trail-name') do
it { should be_encrypted }
end
2018-02-20 03:09:51 +00:00
### Test that the specified trail is a multi-region trail
2018-02-14 01:42:39 +00:00
describe aws_cloudtrail_trail('trail-name') do
it { should be_multi_region_trail }
end
<br>
2018-01-23 16:26:27 +00:00
## Properties
2018-02-13 19:30:07 +00:00
* `s3_bucket_name`, `trail_arn`, `cloud_watch_logs_role_arn`, `cloud_watch_logs_log_group_arn`, `kms_key_id`, `home_region`,
2018-02-14 01:42:39 +00:00
<br>
## Property Examples
2018-02-15 02:23:29 +00:00
### s3\_bucket\_name
2018-01-23 16:26:27 +00:00
Specifies the name of the Amazon S3 bucket designated for publishing log files.
describe aws_cloudtrail_trail('trail-name') do
its('s3_bucket_name') { should cmp "s3-bucket-name" }
end
2018-02-15 02:23:29 +00:00
### trail\_arn
2018-01-23 16:26:27 +00:00
The ARN identifier of the specified trail. An ARN uniquely identifies the trail within AWS.
describe aws_cloudtrail_trail('trail-name') do
its('trail_arn') { should cmp "arn:aws:cloudtrail:us-east-1:484747447281:trail/trail-name" }
end
2018-02-15 02:23:29 +00:00
### cloud\_watch\_logs\_role\_arn
2018-01-23 16:26:27 +00:00
Specifies the role for the CloudWatch Logs endpoint to assume to write to a user\'s log group.
describe aws_cloudtrail_trail('trail-name') do
its('cloud_watch_logs_role_arn') { should include "arn:aws:iam:::role/CloudTrail_CloudWatchLogs_Role" }
end
2018-02-15 02:23:29 +00:00
### cloud\_watch\_logs\_log\_group\_arn
2018-01-23 16:26:27 +00:00
Specifies a log group name using an Amazon Resource Name (ARN), a unique identifier that represents the log group to which CloudTrail logs will be delivered.
describe aws_cloudtrail_trail('trail-name') do
its('cloud_watch_logs_log_group_arn') { should include "arn:aws:logs:us-east-1::log-group:test:*" }
end
2018-02-15 02:23:29 +00:00
### kms\_key\_id
2018-01-23 16:26:27 +00:00
Specifies the KMS key ID to used to encrypt the logs delivered by CloudTrail.
describe aws_cloudtrail_trail('trail-name') do
its('kms_key_id') { should include "key-arn" }
end
2018-02-15 02:23:29 +00:00
### home\_region
2018-01-23 16:26:27 +00:00
Specifies the region in which the trail was created.
describe aws_cloudtrail_trail('trail-name') do
its('home_region') { should include "us-east-1" }
end
2018-02-13 19:30:07 +00:00
<br>
2018-01-23 16:26:27 +00:00
## Matchers
2018-02-16 03:07:18 +00:00
This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
2018-01-23 16:26:27 +00:00
2018-02-15 02:23:29 +00:00
### be\_multi\_region\_trail
2018-01-23 16:26:27 +00:00
2018-02-20 03:09:51 +00:00
The test will pass if the identified trail is a multi-region trail.
2018-01-23 16:26:27 +00:00
describe aws_cloudtrail_trail('trail-name') do
it { should be_multi_region_trail }
end
2018-02-15 02:23:29 +00:00
### be\_encrypted
2018-01-23 16:26:27 +00:00
The test will pass if the logs delivered by the identified trail is encrypted.
describe aws_cloudtrail_trail('trail-name') do
it { should be_encrypted }
end
2018-02-15 02:23:29 +00:00
### be\_log\_file\_validation\_enabled
2018-01-23 16:26:27 +00:00
The test will pass if the identified trail has log file integrity validation is enabled.
describe aws_cloudtrail_trail('trail-name') do
it { should be_log_file_validation_enabled }
end