-
Notifications
You must be signed in to change notification settings - Fork 1
/
honeytoken-s3.tf
43 lines (40 loc) · 1.01 KB
/
honeytoken-s3.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
resource "aws_s3_bucket" "honey_s3_bucket" {
count = var.enable_s3_event_selector ? 1 : 0
bucket = "data-bucket-${random_pet.pet.id}-${random_id.id.hex}"
}
resource "aws_s3_object" "object" {
count = var.enable_s3_event_selector ? 1 : 0
bucket = aws_s3_bucket.honey_s3_bucket[0].id
key = "users_data.csv"
source = "users_data.csv"
etag = filemd5("users_data.csv")
}
locals {
s3_event_selectors = var.enable_s3_event_selector ? [
{
name = "Log GetObject events for my S3 bucket"
field_selectors = [
{
field = "eventCategory"
equals = ["Data"]
},
{
field = "eventName"
equals = ["GetObject"]
},
{
field = "resources.ARN"
starts_with = ["${aws_s3_bucket.honey_s3_bucket[0].arn}/"]
},
{
field = "readOnly"
equals = ["true"]
},
{
field = "resources.type"
equals = ["AWS::S3::Object"]
}
]
}
] : []
}