Skip to content

Commit 466204b

Browse files
author
Brandon O'Connor
committed
moved data source to data file
1 parent 8e8b7d0 commit 466204b

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

data.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
data "aws_caller_identity" "current" {}
22

33
data "aws_elb_service_account" "main" {}
4+
5+
data "aws_iam_policy_document" "bucket_policy" {
6+
statement {
7+
sid = "AllowToPutLoadBalancerLogsToS3Bucket"
8+
9+
actions = [
10+
"s3:PutObject",
11+
]
12+
13+
resources = [
14+
"arn:aws:s3:::${var.log_bucket_name}/${var.log_location_prefix}/AWSLogs/${data.aws_caller_identity.current.account_id}/*",
15+
]
16+
17+
principals {
18+
type = "AWS"
19+
identifiers = ["arn:aws:iam::${data.aws_elb_service_account.main.id}:root"]
20+
}
21+
}
22+
}

main.tf

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,6 @@ resource "aws_alb" "main" {
2121
depends_on = ["aws_s3_bucket.log_bucket"]
2222
}
2323

24-
data "aws_iam_policy_document" "bucket_policy" {
25-
statement {
26-
sid = "AllowToPutLoadBalancerLogsToS3Bucket"
27-
28-
actions = [
29-
"s3:PutObject",
30-
]
31-
32-
resources = [
33-
"arn:aws:s3:::${var.log_bucket_name}/${var.log_location_prefix}/AWSLogs/${data.aws_caller_identity.current.account_id}/*",
34-
]
35-
36-
principals {
37-
type = "AWS"
38-
identifiers = ["arn:aws:iam::${data.aws_elb_service_account.main.id}:root"]
39-
}
40-
}
41-
}
42-
4324
resource "aws_s3_bucket" "log_bucket" {
4425
bucket = "${var.log_bucket_name}"
4526
policy = "${var.bucket_policy == "" ? data.aws_iam_policy_document.bucket_policy.json : var.bucket_policy}"

0 commit comments

Comments
 (0)