Skip to content

Commit 8d30c4b

Browse files
committed
CCM-11586: does consolidation make sonar happy
1 parent 108dfc1 commit 8d30c4b

File tree

3 files changed

+48
-51
lines changed

3 files changed

+48
-51
lines changed

infrastructure/terraform/components/api/s3_bucket_logging.tf

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,47 @@ resource "aws_s3_bucket_public_access_block" "logging" {
3636
restrict_public_buckets = true
3737
}
3838

39-
###
40-
# Bucket logging definitions past here
41-
###
39+
data "aws_iam_policy_document" "logging" {
40+
statement {
41+
effect = "Deny"
42+
actions = ["s3:*"]
43+
resources = [
44+
aws_s3_bucket.logging.arn,
45+
"${aws_s3_bucket.logging.arn}/*",
46+
]
4247

43-
resource "aws_s3_bucket_logging" "truststore" {
44-
bucket = aws_s3_bucket.truststore.id
48+
principals {
49+
type = "AWS"
50+
identifiers = ["*"]
51+
}
52+
53+
condition {
54+
test = "Bool"
55+
variable = "aws:SecureTransport"
56+
values = [
57+
false
58+
]
59+
}
60+
}
61+
62+
statement {
63+
sid = "s3-log-delivery"
64+
effect = "Allow"
65+
66+
principals {
67+
type = "Service"
68+
identifiers = ["logging.s3.amazonaws.com"]
69+
}
4570

46-
target_bucket = aws_s3_bucket.logging.bucket
47-
target_prefix = "${aws_s3_bucket.truststore.bucket}/"
71+
actions = ["s3:PutObject"]
72+
73+
resources = [
74+
"${aws_s3_bucket.logging.arn}/*",
75+
]
76+
}
77+
}
78+
79+
resource "aws_s3_bucket_policy" "logging" {
80+
bucket = aws_s3_bucket.logging.id
81+
policy = data.aws_iam_policy_document.logging.json
4882
}

infrastructure/terraform/components/api/s3_bucket_policy_logging.tf

Lines changed: 0 additions & 44 deletions
This file was deleted.

infrastructure/terraform/components/api/s3_bucket_truststore.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ resource "aws_s3_bucket_public_access_block" "truststore" {
4444
restrict_public_buckets = true
4545
}
4646

47+
resource "aws_s3_bucket_logging" "truststore" {
48+
bucket = aws_s3_bucket.truststore.id
49+
50+
target_bucket = aws_s3_bucket.logging.bucket
51+
target_prefix = "${aws_s3_bucket.truststore.bucket}/"
52+
}
53+
4754
# In manually configured (e.g. dev main, nonprod main, prod main) add lifecycle policy to permit manual management of cert
4855
resource "aws_s3_object" "placeholder_truststore" {
4956
count = var.manually_configure_mtls_truststore ? 1 : 0

0 commit comments

Comments
 (0)