Skip to content

Commit 04a59a6

Browse files
CA-202 - Replace S3 deprecated arguments (#14)
* Updates versions file to allow update of aws provider. * Replaces source_json argument by source_policy_documents to remove warning. * Replaces bucket encryption configuration argument for resource block to fix warning. * Updates version to allow aws provider update. * Runs fmt. * Adds enable public access block functionality. * Replaces deprecated arguments by resource blocks. * Updates with newer version. * Fixes typo. * Updates versions. * Updates version to 0.13. * Runs fmt, lint and docs.
1 parent 166820e commit 04a59a6

File tree

7 files changed

+31
-18
lines changed

7 files changed

+31
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Tamr S3 Module Repo
22

3+
## v1.2.1 - April 21st 2022
4+
* Replaces deprecated S3 arguments with resource blocks.
5+
* Replaces deprecated IAM policy document argument names.
6+
37
## v1.2.0 - April 18th 2022
48
* Resolves S3 bucket public access block tfsec vulnerability.
59

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.0
1+
1.2.1

examples/iam-policy-submodule/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ data "aws_s3_bucket" "existing-bucket" {
44
}
55

66
module "existing-bucket-iam-0" {
7-
# source = "git::https://github.com/Datatamer/terraform-aws-s3.git//modules/bucket-iam-policy?ref=1.0.0"
7+
# source = "git::https://github.com/Datatamer/terraform-aws-s3.git//modules/bucket-iam-policy?ref=1.2.1"
88
source = "../../modules/bucket-iam-policy"
99
bucket_name = data.aws_s3_bucket.existing-bucket.id
1010
read_write_paths = ["some/read-write-folder"]
1111
tags = var.tags
1212
}
1313

1414
module "existing-bucket-iam-1" {
15-
# source = "git::https://github.com/Datatamer/terraform-aws-s3.git//modules/bucket-iam-policy?ref=1.0.0"
15+
# source = "git::https://github.com/Datatamer/terraform-aws-s3.git//modules/bucket-iam-policy?ref=1.2.1"
1616
source = "../../modules/bucket-iam-policy"
1717
bucket_name = data.aws_s3_bucket.existing-bucket.id
1818
read_write_paths = ["another/read-write-folder"]

examples/minimal/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module "minimal" {
2-
# source = "git::https://github.com/Datatamer/terraform-aws-s3?ref=1.0.0"
2+
# source = "git::https://github.com/Datatamer/terraform-aws-s3?ref=1.2.1"
33
source = "../../"
44
bucket_name = var.test_bucket_name
55
read_only_paths = var.read_only_paths # ["path/to/ro-folder"]

modules/bucket-iam-policy/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ data "aws_iam_policy_document" "ro_source_policy_doc" {
2929
data "aws_iam_policy_document" "path_specific_ro_doc" {
3030
count = length(local.ro_paths) == 0 ? 0 : 1
3131

32-
version = "2012-10-17"
33-
source_json = data.aws_iam_policy_document.ro_source_policy_doc[0].json
32+
version = "2012-10-17"
33+
source_policy_documents = [data.aws_iam_policy_document.ro_source_policy_doc[0].json]
3434

3535
dynamic "statement" {
3636
for_each = local.ro_paths_map
@@ -86,8 +86,8 @@ data "aws_iam_policy_document" "rw_source_policy_doc" {
8686
data "aws_iam_policy_document" "path_specific_rw_doc" {
8787
count = length(var.read_write_paths) == 0 ? 0 : 1
8888

89-
version = "2012-10-17"
90-
source_json = data.aws_iam_policy_document.rw_source_policy_doc[0].json
89+
version = "2012-10-17"
90+
source_policy_documents = [data.aws_iam_policy_document.rw_source_policy_doc[0].json]
9191

9292
dynamic "statement" {
9393
for_each = local.rw_paths_map

modules/encrypted-bucket/main.tf

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1+
2+
#tfsec:ignore:aws-s3-enable-bucket-encryption:tfsec is yet not detecting the aws_s3_bucket_server_side_encryption_configuration resource block. https://github.com/aquasecurity/defsec/issues/489
13
#tfsec:ignore:aws-s3-enable-bucket-logging tfsec:ignore:aws-s3-enable-versioning
24
resource "aws_s3_bucket" "new_bucket" {
35
bucket = var.bucket_name
4-
acl = "private"
5-
6-
server_side_encryption_configuration {
7-
rule {
8-
apply_server_side_encryption_by_default {
9-
sse_algorithm = "AES256"
10-
}
11-
}
12-
}
136

147
force_destroy = var.force_destroy
158
tags = var.tags
169
}
1710

11+
resource "aws_s3_bucket_server_side_encryption_configuration" "encryption_for_new_bucket" {
12+
bucket = aws_s3_bucket.new_bucket.id
13+
rule {
14+
apply_server_side_encryption_by_default {
15+
sse_algorithm = "AES256"
16+
}
17+
}
18+
}
19+
1820
# Bucket policy to enforce AES256 server-side-encryption
1921
resource "aws_s3_bucket_policy" "sse_bucket_policy" {
2022
bucket = aws_s3_bucket.new_bucket.id
@@ -27,6 +29,13 @@ resource "aws_s3_bucket_policy" "sse_bucket_policy" {
2729
)
2830
}
2931

32+
# Sets S3 bucket ACL
33+
resource "aws_s3_bucket_acl" "acl_for_new_bucket" {
34+
bucket = aws_s3_bucket.new_bucket.id
35+
acl = "private"
36+
}
37+
38+
# Enabling S3 bucket public access block
3039
resource "aws_s3_bucket_public_access_block" "for_new_bucket" {
3140
bucket = aws_s3_bucket.new_bucket.id
3241

test_examples/minimal/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module "minimal" {
2-
# source = "git::https://github.com/Datatamer/terraform-aws-s3?ref=1.0.0"
2+
# source = "git::https://github.com/Datatamer/terraform-aws-s3?ref=1.2.1"
33
source = "../../examples/minimal"
44
test_bucket_name = var.test_bucket_name
55
read_only_paths = var.read_only_paths

0 commit comments

Comments
 (0)