Skip to content

Commit d474052

Browse files
authored
Merge pull request #8 from egarbi/master
Enhance retrieving of elb_account in s3_logs module
2 parents afaabee + de3e0c9 commit d474052

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ module "s3_logs" {
235235
source = "./s3-logs"
236236
name = "${var.name}"
237237
environment = "${var.environment}"
238-
account_id = "${module.defaults.s3_logs_account_id}"
239238
logs_expiration_enabled = "${var.logs_expiration_enabled}"
240239
logs_expiration_days = "${var.logs_expiration_days}"
241240
}

s3-logs/main.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ variable "name" {
44
variable "environment" {
55
}
66

7-
variable "account_id" {
8-
}
9-
107
variable "logs_expiration_enabled" {
118
default = false
129
}
@@ -15,12 +12,14 @@ variable "logs_expiration_days" {
1512
default = 30
1613
}
1714

15+
data "aws_elb_service_account" "main" {}
16+
1817
data "template_file" "policy" {
1918
template = "${file("${path.module}/policy.json")}"
2019

2120
vars = {
2221
bucket = "${var.name}-${var.environment}-logs"
23-
account_id = "${var.account_id}"
22+
elb_account_id = "${data.aws_elb_service_account.main.arn}"
2423
}
2524
}
2625

s3-logs/policy.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"Action": "s3:PutObject",
66
"Effect": "Allow",
77
"Principal": {
8-
"AWS": "arn:aws:iam::${account_id}:root"
8+
"AWS": "${elb_account_id}"
99
},
1010
"Resource": "arn:aws:s3:::${bucket}/*",
1111
"Sid": "log-bucket-policy"

0 commit comments

Comments
 (0)