Skip to content

Commit

Permalink
* 2.5.8 -- 2024-07-01
Browse files Browse the repository at this point in the history
  - s3-access-logs
    - update policy to match documentation, add nlb-logs/*
  • Loading branch information
badra001 committed Jul 1, 2024
1 parent 7d7b7ee commit 1f4e358
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,7 @@
* 2.5.7 -- 2024-04-22
- s3-config-org
- add output s3_sqs_id

* 2.5.8 -- 2024-07-01
- s3-access-logs
- update policy to match documentation, add nlb-logs/*
2 changes: 1 addition & 1 deletion common/version.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
locals {
_module_version = "2.5.7"
_module_version = "2.5.8"
}
39 changes: 32 additions & 7 deletions s3-access-logs/policy_data.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# see:
# * https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-access-logs.html
# * https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html#access-logging-bucket-permissions

data "aws_iam_policy_document" "logs_s3" {
statement {
sid = "AWSLogWrite"
Expand All @@ -23,6 +27,16 @@ data "aws_iam_policy_document" "logs_s3" {
variable = "s3:x-amz-acl"
values = ["bucket-owner-full-control"]
}
condition {
test = "StringEquals"
variable = "aws:SourceAccount"
values = [local.account_id]
}
condition {
test = "ArnLike"
variable = "aws:SourceArn"
values = [format("arn:%v:logs:%v:%v:*", data.aws_arn.current.partition, var.region, local.account_id)]
}
}
statement {
sid = "AWSLogDeliveryAclCheck"
Expand All @@ -33,17 +47,28 @@ data "aws_iam_policy_document" "logs_s3" {
type = "Service"
identifiers = ["delivery.logs.amazonaws.com"]
}
condition {
test = "StringEquals"
variable = "aws:SourceAccount"
values = [local.account_id]
}
condition {
test = "ArnLike"
variable = "aws:SourceArn"
values = [format("arn:%v:logs:%v:%v:*", data.aws_arn.current.partition, var.region, local.account_id)]
}
}

# https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html#access-logging-bucket-permissions
statement {
sid = "AWSALBAccessLog"
effect = "Allow"
actions = ["s3:PutObject"]
resources = ["${aws_s3_bucket.logs.arn}/alb-logs/*"]
sid = "AWSALBAccessLog"
effect = "Allow"
actions = ["s3:PutObject"]
resources = [
"${aws_s3_bucket.logs.arn}/alb-logs/*",
"${aws_s3_bucket.logs.arn}/nlb-logs/*",
]
principals {
type = "AWS"
# identifiers = [ formatlist("arn:%v:iam::%v:root",data.aws_arn.current.partition,local.logs_alb_accounts) ]
type = "AWS"
identifiers = [format("arn:%v:iam::%v:root", data.aws_arn.current.partition, local.logs_alb_account)]
}
}
Expand Down

0 comments on commit 1f4e358

Please sign in to comment.