Use UpdateTrail with a CLI - AWS SDK Code Examples

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

Use UpdateTrail with a CLI

The following code examples show how to use UpdateTrail.

CLI
AWS CLI

To update a trail

The following update-trail command updates a trail to use an existing bucket for log delivery:

aws cloudtrail update-trail --name Trail1 --s3-bucket-name my-bucket

Output:

{ "IncludeGlobalServiceEvents": true, "Name": "Trail1", "TrailARN": "arn:aws:cloudtrail:us-west-2:123456789012:trail/Trail1", "LogFileValidationEnabled": false, "IsMultiRegionTrail": true, "S3BucketName": "my-bucket" }
  • For API details, see UpdateTrail in AWS CLI Command Reference.

PowerShell
Tools for PowerShell

Example 1: Updates the specified trail so that global service events (such as those from IAM) are recorded and changes the common key prefix of the log files going forwards to be 'globallogs'.

Update-CTTrail -Name "awscloudtrail-example" -IncludeGlobalServiceEvents $true -S3KeyPrefix "globallogs"

Example 2: Updates the specified trail so notifications about new log deliveries are sent to the specified SNS topic.

Update-CTTrail -Name "awscloudtrail-example" -SnsTopicName "mlog-deliverytopic2"

Example 3: Updates the specified trail so logs are delivered to a different bucket.

Update-CTTrail -Name "awscloudtrail-example" -S3BucketName "otherlogs"
  • For API details, see UpdateTrail in AWS Tools for PowerShell Cmdlet Reference.