Skip to content

Commit 68bce40

Browse files
committed
NRL-1188 Ensure S3 buckets are compliant
1 parent 47844be commit 68bce40

File tree

2 files changed

+112
-0
lines changed
  • terraform/account-wide-infrastructure/modules

2 files changed

+112
-0
lines changed

terraform/account-wide-infrastructure/modules/athena/s3.tf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@ resource "aws_s3_bucket" "athena" {
22
bucket = "athena"
33
}
44

5+
resource "aws_s3_bucket_policy" "athena" {
6+
bucket = "athena"
7+
8+
policy = jsonencode({
9+
Version = "2012-10-17"
10+
Id = "athena-policy"
11+
Statement = [
12+
{
13+
Sid = "HTTPSOnly"
14+
Effect = "Deny"
15+
Principal = {
16+
"AWS" : "*"
17+
}
18+
Action = "s3:*"
19+
Resource = [
20+
aws_s3_bucket.athena.arn,
21+
"${aws_s3_bucket.athena.arn}/*",
22+
]
23+
Condition = {
24+
Bool = {
25+
"aws:SecureTransport" = "false"
26+
}
27+
}
28+
},
29+
]
30+
})
31+
}
32+
533
resource "aws_s3_bucket_public_access_block" "athena-public-access-block" {
634
bucket = aws_s3_bucket.athena.id
735

terraform/account-wide-infrastructure/modules/glue/s3.tf

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,34 @@ resource "aws_s3_bucket" "source-data-bucket" {
33
bucket = "source-data-bucket"
44
}
55

6+
resource "aws_s3_bucket_policy" "source-data-bucket" {
7+
bucket = "source-data-bucket"
8+
9+
policy = jsonencode({
10+
Version = "2012-10-17"
11+
Id = "source-data-bucket-policy"
12+
Statement = [
13+
{
14+
Sid = "HTTPSOnly"
15+
Effect = "Deny"
16+
Principal = {
17+
"AWS" : "*"
18+
}
19+
Action = "s3:*"
20+
Resource = [
21+
aws_s3_bucket.source-data-bucket.arn,
22+
"${aws_s3_bucket.source-data-bucket.arn}/*",
23+
]
24+
Condition = {
25+
Bool = {
26+
"aws:SecureTransport" = "false"
27+
}
28+
}
29+
},
30+
]
31+
})
32+
}
33+
634
resource "aws_s3_bucket_public_access_block" "source-data-bucket-public-access-block" {
735
bucket = aws_s3_bucket.source-data-bucket.id
836

@@ -18,6 +46,34 @@ resource "aws_s3_bucket" "target-data-bucket" {
1846
bucket = "target-data-bucket"
1947
}
2048

49+
resource "aws_s3_bucket_policy" "target-data-bucket" {
50+
bucket = "target-data-bucket"
51+
52+
policy = jsonencode({
53+
Version = "2012-10-17"
54+
Id = "target-data-bucket-policy"
55+
Statement = [
56+
{
57+
Sid = "HTTPSOnly"
58+
Effect = "Deny"
59+
Principal = {
60+
"AWS" : "*"
61+
}
62+
Action = "s3:*"
63+
Resource = [
64+
aws_s3_bucket.target-data-bucket.arn,
65+
"${aws_s3_bucket.target-data-bucket.arn}/*",
66+
]
67+
Condition = {
68+
Bool = {
69+
"aws:SecureTransport" = "false"
70+
}
71+
}
72+
},
73+
]
74+
})
75+
}
76+
2177
resource "aws_s3_bucket_public_access_block" "target-data-bucket-public-access-block" {
2278
bucket = aws_s3_bucket.target-data-bucket.id
2379

@@ -32,6 +88,34 @@ resource "aws_s3_bucket" "code-bucket" {
3288
bucket = "code-bucket"
3389
}
3490

91+
resource "aws_s3_bucket_policy" "code-bucket" {
92+
bucket = "code-bucket"
93+
94+
policy = jsonencode({
95+
Version = "2012-10-17"
96+
Id = "code-bucket-policy"
97+
Statement = [
98+
{
99+
Sid = "HTTPSOnly"
100+
Effect = "Deny"
101+
Principal = {
102+
"AWS" : "*"
103+
}
104+
Action = "s3:*"
105+
Resource = [
106+
aws_s3_bucket.code-bucket.arn,
107+
"${aws_s3_bucket.code-bucket.arn}/*",
108+
]
109+
Condition = {
110+
Bool = {
111+
"aws:SecureTransport" = "false"
112+
}
113+
}
114+
},
115+
]
116+
})
117+
}
118+
35119
resource "aws_s3_bucket_public_access_block" "code-bucket-public-access-block" {
36120
bucket = aws_s3_bucket.code-bucket.id
37121

0 commit comments

Comments
 (0)