Skip to main content

Basic CloudTrail Trail

๐Ÿ“ฆ Overviewโ€‹

This Terraform module provisions a basic AWS CloudTrail trail to log API calls across your AWS account.
It captures governance, compliance, and operational activity and stores the logs in a designated S3 bucket.


โœ… Key Featuresโ€‹

  • Creates a named CloudTrail trail scoped to the current region
  • Sends API activity logs to a specified Amazon S3 bucket
  • Enables foundational observability and traceability
  • Tags the trail with environment-specific metadata

๐Ÿ’ผ Use Casesโ€‹

  • Auditing AWS account activity
  • Meeting compliance or regulatory log retention requirements
  • Troubleshooting operational or security incidents

๐Ÿ“ฅ Input Variablesโ€‹

NameTypeDescription
regionstringAWS region for trail creation
trail_namestringName of the CloudTrail trail
s3_bucket_namestringName of the S3 bucket that will store log files
environmentstringEnvironment tag for resource labeling (e.g., dev/prod)

๐Ÿ“ค Outputsโ€‹

NameDescription
cloudtrail_trail_arnARN of the created CloudTrail trail
cloudtrail_trail_nameName of the created trail

๐Ÿš€ Deployment Readinessโ€‹

  • โœ… Compatible with Terraform 1.0+
  • โœ… Requires AWS Provider 5.x or later
  • โ˜๏ธ Assumes the target S3 bucket is pre-created

๐Ÿ› ๏ธ Example Usageโ€‹

module "cloudtrail_basic" {
source = "git::ssh://git@github.com/archiphire/aws-level-1-modules.git//logging/cloudtrail-basic?ref=v1.0.0"

region = "us-east-1"
trail_name = "archiphire-trail"
s3_bucket_name = "archiphire-cloudtrail-logs"
environment = "dev"
}
terraform init
terraform plan
terraform apply

or

tofu init
tofu plan
tofu apply

๐Ÿงน Cleanup Optionsโ€‹

Terraform Destroy:

terraform destroy

or

tofu destroy

Manual Deletion:

aws cloudtrail delete-trail --name archiphire-trail

๐Ÿ›ก๏ธ Notesโ€‹

This is a Level 1 logging module designed for basic CloudTrail setup. To enable multi-region logging, CloudWatch integration, or cross-account delivery, extend this with a Level 2 observability or compliance stack.

๐Ÿ”’ Deployment Package Noticeโ€‹

This module is part of the Level 1 AWS License Tier. To access the full deployment package and source code, subscribe to Archiphire.