File tree Expand file tree Collapse file tree 2 files changed +19
-19
lines changed Expand file tree Collapse file tree 2 files changed +19
-19
lines changed Original file line number Diff line number Diff line change 11data "aws_caller_identity" "current" {}
22
33data "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+ }
Original file line number Diff line number Diff 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-
4324resource "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 } "
You can’t perform that action at this time.
0 commit comments