Skip to content

Commit d3eb513

Browse files
committed
CCM-11586: forgot to save
1 parent 00faa97 commit d3eb513

File tree

1 file changed

+28
-32
lines changed

1 file changed

+28
-32
lines changed

infrastructure/terraform/components/api/s3_bucket_truststore.tf

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -44,42 +44,38 @@ 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-
54-
# In manually configured (e.g. dev main, nonprod main, prod main) add lifecycle policy to permit manual management of cert
55-
resource "aws_s3_object" "placeholder_truststore" {
56-
count = var.manually_configure_mtls_truststore ? 1 : 0
57-
bucket = aws_s3_bucket.truststore.bucket
58-
key = "truststore.pem"
59-
content = module.supplier_ssl[0].cacert_pem
47+
data "aws_iam_policy_document" "truststore" {
48+
statement {
49+
effect = "Deny"
50+
actions = ["s3:*"]
51+
resources = [
52+
aws_s3_bucket.truststore.arn,
53+
"${aws_s3_bucket.truststore.arn}/*",
54+
]
6055

61-
depends_on = [
62-
aws_s3_bucket_versioning.truststore,
63-
module.supplier_ssl
64-
]
56+
principals {
57+
type = "AWS"
58+
identifiers = ["*"]
59+
}
6560

66-
lifecycle {
67-
ignore_changes = [
68-
content
69-
]
61+
condition {
62+
test = "Bool"
63+
variable = "aws:SecureTransport"
64+
values = [
65+
false
66+
]
67+
}
7068
}
7169
}
7270

73-
# In non-manually configured env (e.g. PR) exclude lifecycle policy so resources are managed
74-
# Requires duplicate block as lifecycle policies cannot be dynamic
75-
resource "aws_s3_object" "placeholder_truststore_nonprod" {
76-
count = !var.manually_configure_mtls_truststore ? 1 : 0
77-
bucket = aws_s3_bucket.truststore.bucket
78-
key = "truststore.pem"
79-
content = module.supplier_ssl[0].cacert_pem
71+
resource "aws_s3_bucket_policy" "truststore" {
72+
bucket = aws_s3_bucket.truststore.id
73+
policy = data.aws_iam_policy_document.truststore.json
74+
}
8075

81-
depends_on = [
82-
aws_s3_bucket_versioning.truststore,
83-
module.supplier_ssl
84-
]
76+
resource "aws_s3_bucket_logging" "truststore" {
77+
bucket = aws_s3_bucket.truststore.id
78+
79+
target_bucket = aws_s3_bucket.logging.bucket
80+
target_prefix = "${aws_s3_bucket.truststore.bucket}/"
8581
}

0 commit comments

Comments
 (0)