Skip to content

Commit ce37ffd

Browse files
Update s3.tf
1 parent eeee794 commit ce37ffd

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

s3.tf

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
resource "aws_s3_bucket" "this" {
22
provider = aws.main
33
bucket = var.project_name
4-
policy = data.aws_iam_policy_document.this.json
5-
6-
block_public_acls = true
7-
4+
policy = data.aws_iam_policy_document.this.json
85
website {
96
redirect_all_requests_to = "https://${var.target_domain}"
107
}
@@ -17,6 +14,15 @@ resource "aws_s3_bucket" "this" {
1714
)
1815
}
1916

17+
resource "aws_s3_bucket_public_access_block" "this" {
18+
bucket = aws_s3_bucket.this.id
19+
20+
block_public_acls = true
21+
block_public_policy = true
22+
ignore_public_acls = true
23+
restrict_public_buckets = true
24+
}
25+
2026
data "aws_iam_policy_document" "this" {
2127
statement {
2228
sid = "Redirect ${var.project_name}"
@@ -44,6 +50,7 @@ data "aws_iam_policy_document" "this" {
4450

4551
resource "aws_kms_key" "this" {
4652
deletion_window_in_days = 10
53+
enable_key_rotation = true
4754
}
4855

4956
resource "aws_s3_bucket_server_side_encryption_configuration" "this" {
@@ -63,12 +70,22 @@ resource "aws_s3_bucket_versioning" "this" {
6370
versioning_configuration {
6471
status = "Enabled"
6572
}
73+
versioning.mfa_delete = true
6674
}
6775

6876
resource "aws_s3_bucket" "log_bucket" {
6977
bucket = "log_bucket"
7078
}
7179

80+
resource "aws_s3_bucket_public_access_block" "log" {
81+
bucket = aws_s3_bucket.log_bucket.id
82+
83+
block_public_acls = true
84+
block_public_policy = true
85+
ignore_public_acls = true
86+
restrict_public_buckets = true
87+
}
88+
7289
resource "aws_s3_bucket_acl" "log_bucket_acl" {
7390
bucket = aws_s3_bucket.log_bucket.id
7491
acl = "log-delivery-write"

0 commit comments

Comments
 (0)