diff --git a/CHANGELOG.md b/CHANGELOG.md index cc89d64..87a2c83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -362,3 +362,7 @@ * 2.5.8 -- 2024-07-01 - s3-access-logs - update policy to match documentation, add nlb-logs/* + +* 2.6.0 -- 2024-07-09 + - cloudtrail + - add variable enable_organization_s3_objectlogging, when usewd with enable_organization, to do data events diff --git a/cloudtrail/README.md b/cloudtrail/README.md index e6fb38f..d412f47 100644 --- a/cloudtrail/README.md +++ b/cloudtrail/README.md @@ -445,7 +445,8 @@ No modules. | [component\_tags](#input\_component\_tags) | Additional tags for Components (s3, kms, ddb) | `map(map(string))` |
{
"ddb": {},
"kms": {},
"s3": {}
}
| no | | [create\_cloudtrail](#input\_create\_cloudtrail) | Flag to enable or disable creation of cloudtrail | `bool` | `true` | no | | [enable\_cloudwatch\_logs](#input\_enable\_cloudwatch\_logs) | Enable CloudWatch Logs for this CloudTrail | `bool` | `true` | no | -| [enable\_organization](#input\_enable\_organization) | Enable CloudTrail as an organization trail. This will only work in the organization master account | `bool` | `false` | no | +| [enable\_organization](#input\_enable\_organization) | Enable CloudTrail as an organization trail. This will only work in the organization master or delegated account | `bool` | `false` | no | +| [enable\_organization\_s3\_objectlogging](#input\_enable\_organization\_s3\_objectlogging) | Enable CloudTrail organization trail S3 data events | `bool` | `false` | no | | [enable\_s3\_sns](#input\_enable\_s3\_sns) | Flag to enable or disable the creation of SNS for the Cloudtrail S3 bucket | `bool` | `false` | no | | [enable\_s3\_sqs](#input\_enable\_s3\_sqs) | Flag to enable or disable the creation of SQS attached to SNS for Cloudtrail S3 bucket | `bool` | `false` | no | | [enable\_sns](#input\_enable\_sns) | Flag to enable or disable the creation of SNS for Cloudtrail (TBD) | `bool` | `false` | no | diff --git a/cloudtrail/cloudtrail.tf b/cloudtrail/cloudtrail.tf index 5c908ad..046b89c 100644 --- a/cloudtrail/cloudtrail.tf +++ b/cloudtrail/cloudtrail.tf @@ -13,6 +13,21 @@ resource "aws_cloudtrail" "this" { cloud_watch_logs_role_arn = var.enable_cloudwatch_logs ? aws_iam_role.cloudtrail[0].arn : null is_organization_trail = var.enable_organization + dynamic "event_selector" { + for_each = var.enable_organization && var.enable_organization_s3_objectlogging ? toset(["s3"]) : toset([]) + iterator = e + + content { + read_write_type = "All" + include_management_events = true + + data_resource { + type = "AWS::S3::Object" + values = [format("arn:%v:s3", data.aws_arn.current.partition)] + } + } + } + tags = merge( local.base_tags, var.tags, diff --git a/cloudtrail/variables.tf b/cloudtrail/variables.tf index b48fb76..d8737e7 100644 --- a/cloudtrail/variables.tf +++ b/cloudtrail/variables.tf @@ -73,7 +73,13 @@ variable "component_tags" { } variable "enable_organization" { - description = "Enable CloudTrail as an organization trail. This will only work in the organization master account" + description = "Enable CloudTrail as an organization trail. This will only work in the organization master or delegated account" + type = bool + default = false +} + +variable "enable_organization_s3_objectlogging" { + description = "Enable CloudTrail organization trail S3 data events" type = bool default = false } diff --git a/common/version.tf b/common/version.tf index c233b5f..b061df5 100644 --- a/common/version.tf +++ b/common/version.tf @@ -1,3 +1,3 @@ locals { - _module_version = "2.5.8" + _module_version = "2.6.0" }