Skip to content

Commit b6f6ba7

Browse files
committed
Create unique logging bucket for Cloudtrail module
Monitoring changes to the Cloudtrail bucket requires the logging bucket to pre-exist, so we need to generate it here. This ensures that the end-to-end process works properly.
1 parent 376c595 commit b6f6ba7

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

aws/cloudtrail/main.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ resource "aws_cloudtrail" "mod" {
1111
tags = var.tags
1212
}
1313

14+
resource "aws_s3_bucket" "logs" {
15+
bucket = "${var.name}-cloudtrail-logs"
16+
acl = "log-delivery-write"
17+
18+
tags = var.tags
19+
}
20+
1421
resource "aws_s3_bucket" "mod" {
1522
bucket = "${var.name}-cloudtrail"
1623
acl = "private"
@@ -19,7 +26,7 @@ resource "aws_s3_bucket" "mod" {
1926
tags = var.tags
2027

2128
logging {
22-
target_bucket = "cloudtrail-logs"
29+
target_bucket = aws_s3_bucket.logs.id
2330
target_prefix = var.name
2431
}
2532
}

0 commit comments

Comments
 (0)