Skip to content

Commit a7f02d2

Browse files
authored
Use object lock enabled (#148)
1 parent 893b544 commit a7f02d2

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

main.tf

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ locals {
22
enabled = module.this.enabled
33
partition = join("", data.aws_partition.current.*.partition)
44

5+
object_lock_enabled = local.enabled && var.object_lock_configuration != null
56
replication_enabled = local.enabled && var.s3_replication_enabled
67
versioning_enabled = local.enabled && var.versioning_enabled
78
transfer_acceleration_enabled = local.enabled && var.transfer_acceleration_enabled
@@ -38,13 +39,7 @@ resource "aws_s3_bucket" "default" {
3839
bucket = local.bucket_name
3940
force_destroy = var.force_destroy
4041

41-
dynamic "object_lock_configuration" {
42-
for_each = var.object_lock_configuration != null ? [1] : []
43-
44-
content {
45-
object_lock_enabled = "Enabled"
46-
}
47-
}
42+
object_lock_enabled = local.object_lock_enabled
4843

4944
tags = module.this.tags
5045
}
@@ -289,7 +284,7 @@ resource "aws_s3_bucket_replication_configuration" "default" {
289284
}
290285

291286
resource "aws_s3_bucket_object_lock_configuration" "default" {
292-
count = local.enabled && var.object_lock_configuration != null ? 1 : 0
287+
count = local.object_lock_enabled ? 1 : 0
293288

294289
bucket = join("", aws_s3_bucket.default.*.id)
295290

test/src/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ require (
3232
github.com/gruntwork-io/go-commons v0.8.0 // indirect
3333
github.com/hashicorp/errwrap v1.0.0 // indirect
3434
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
35-
github.com/hashicorp/go-getter v1.5.9 // indirect
35+
github.com/hashicorp/go-getter v1.5.11 // indirect
3636
github.com/hashicorp/go-multierror v1.1.0 // indirect
3737
github.com/hashicorp/go-safetemp v1.0.0 // indirect
3838
github.com/hashicorp/go-version v1.3.0 // indirect

test/src/go.sum

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF
9898
github.com/alexflint/go-filemutex v0.0.0-20171022225611-72bdc8eae2ae/go.mod h1:CgnQgUtFrFz9mxFNtED3jI5tLDjKlOM+oUF/sTk6ps0=
9999
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
100100
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
101+
github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0=
101102
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
102103
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
103104
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
@@ -458,8 +459,9 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv
458459
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
459460
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
460461
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
461-
github.com/hashicorp/go-getter v1.5.9 h1:b7ahZW50iQiUek/at3CvZhPK1/jiV6CtKcsJiR6E4R0=
462462
github.com/hashicorp/go-getter v1.5.9/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXjMEgDD8+i7ZI=
463+
github.com/hashicorp/go-getter v1.5.11 h1:wioTuNmaBU3IE9vdFtFMcmZWj0QzLc6DYaP6sNe5onY=
464+
github.com/hashicorp/go-getter v1.5.11/go.mod h1:9i48BP6wpWweI/0/+FBjqLrp9S8XtwUGjiu0QkWHEaY=
463465
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
464466
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
465467
github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I=
@@ -479,6 +481,7 @@ github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09
479481
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
480482
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
481483
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
484+
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
482485
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
483486
github.com/hashicorp/hcl/v2 v2.9.1 h1:eOy4gREY0/ZQHNItlfuEZqtcQbXIxzojlP301hDpnac=
484487
github.com/hashicorp/hcl/v2 v2.9.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg=

0 commit comments

Comments
 (0)