-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.tf
31 lines (27 loc) · 956 Bytes
/
data.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
data "aws_caller_identity" "current" {}
data "aws_canonical_user_id" "current" {}
data "aws_cloudfront_log_delivery_canonical_user_id" "cloudfront" {}
data "aws_region" "current" {}
data "aws_iam_policy_document" "waf_logging" {
count = var.provision_cloudfront == true ? 1 : 0
version = "2012-10-17"
statement {
effect = "Allow"
principals {
identifiers = ["delivery.logs.amazonaws.com"]
type = "Service"
}
actions = ["logs:CreateLogStream", "logs:PutLogEvents"]
resources = ["${aws_cloudwatch_log_group.waf_cloudwatch_logs[0].arn}:*"]
condition {
test = "ArnLike"
values = ["arn:aws:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:*"]
variable = "aws:SourceArn"
}
condition {
test = "StringEquals"
values = [tostring(data.aws_caller_identity.current.account_id)]
variable = "aws:SourceAccount"
}
}
}