-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsns-topic-data-protection-policy.tf
90 lines (81 loc) · 3.02 KB
/
sns-topic-data-protection-policy.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
locals {
data_protection_policy = var.data_protection_policy != null ? (
jsonencode(
merge(
{
Name = "__default_data_protection_policy"
Description = "Managed by Terraform"
Version = "2021-06-01"
},
{
Statement = [
for sid, statement in var.data_protection_policy.statements :
{
Sid = sid
DataDirection = statement.data_direction
Principal = statement.principals
DataIdentifier = statement.data_identifiers
Operation = merge(
statement.operation.audit != null ? {
Audit = {
SampleRate = statement.operation.audit.sample_rate
FindingsDestination = merge(
statement.operation.audit.destinations.cloudwatch_log_group != null ? {
CloudWatchLogs = {
LogGroup = statement.operation.audit.destinations.cloudwatch_log_group
}
} : {},
statement.operation.audit.destinations.s3_bucket_name != null ? {
S3 = {
Bucket = statement.operation.audit.destinations.s3_bucket_name
}
} : {},
statement.operation.audit.destinations.firehose_delivery_stream != null ? {
Firehose = {
DeliveryStream = statement.operation.audit.destinations.firehose_delivery_stream
}
} : {}
)
}
} : {},
statement.operation.deny != null ? {
Deny = {}
} : {},
statement.operation.deidentify != null ? {
Deidentify = merge(
statement.operation.deidentify.mask_with_character != null ? {
MaskConfig = {
MaskWithCharacter = statement.operation.deidentify.mask_with_character
}
} : {},
statement.operation.deidentify.redact != null ? {
RedactConfig = {}
} : {}
)
} : {}
)
}
]
},
var.data_protection_policy.configuration != null ? (
{
Configuration = {
CustomDataIdentifier = [
for name, regex in var.data_protection_policy.configuration.custom_data_identifiers :
{
Name = name
Regex = regex
}
]
}
}
) : {}
)
)
) : null
}
resource "aws_sns_topic_data_protection_policy" "data_protection_policy" {
count = var.data_protection_policy != null ? 1 : 0
arn = aws_sns_topic.sns_topic.arn
policy = local.data_protection_policy
}