Skip to content

Commit 31d5bc2

Browse files
add intelligent tiering lifecycle policy (#2512)
1 parent b5030a1 commit 31d5bc2

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

terraform/core/10-aws-s3-buckets.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ module "landing_zone" {
4848
expired_object_delete_marker = true
4949
expire_noncurrent_objects_days = 30
5050
abort_multipart_days = 30
51+
enable_intelligent_tiering = true
5152
}
5253

5354
module "raw_zone" {
@@ -77,6 +78,7 @@ module "raw_zone" {
7778
] : []
7879
)
7980
include_backup_policy_tags = false
81+
enable_intelligent_tiering = true
8082
}
8183

8284
module "refined_zone" {
@@ -105,6 +107,7 @@ module "refined_zone" {
105107
] : []
106108
)
107109
include_backup_policy_tags = false
110+
enable_intelligent_tiering = true
108111
}
109112

110113
module "trusted_zone" {
@@ -127,4 +130,5 @@ module "trusted_zone" {
127130
] : []
128131
)
129132
include_backup_policy_tags = false
133+
enable_intelligent_tiering = true
130134
}

terraform/modules/s3-bucket/02-inputs-optional.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,15 @@ variable "expired_object_delete_marker" {
162162
type = bool
163163
default = false
164164
}
165+
166+
variable "enable_intelligent_tiering" {
167+
description = "Whether to enable S3 Intelligent Tiering for the bucket"
168+
type = bool
169+
default = false
170+
}
171+
172+
variable "intelligent_tiering_days" {
173+
description = "Number of days after which to transition objects to Intelligent Tiering. Set to 0 for immediate transition."
174+
type = number
175+
default = 0
176+
}

terraform/modules/s3-bucket/10-s3-bucket.tf

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ resource "aws_s3_bucket_lifecycle_configuration" "bucket" {
171171
var.expire_objects_days != null ||
172172
var.expire_noncurrent_objects_days != null ||
173173
var.abort_multipart_days != null ||
174-
var.expired_object_delete_marker
174+
var.expired_object_delete_marker ||
175+
var.enable_intelligent_tiering
175176
) ? 1 : 0
176177
bucket = aws_s3_bucket.bucket.id
177178

@@ -242,6 +243,22 @@ resource "aws_s3_bucket_lifecycle_configuration" "bucket" {
242243
}
243244
}
244245
}
246+
247+
# Rule for s3 intelligent tiering
248+
dynamic "rule" {
249+
for_each = var.enable_intelligent_tiering ? [1] : []
250+
content {
251+
id = "intelligent-tiering"
252+
status = "Enabled"
253+
254+
filter {}
255+
256+
transition {
257+
days = var.intelligent_tiering_days
258+
storage_class = "INTELLIGENT_TIERING"
259+
}
260+
}
261+
}
245262
}
246263

247264
resource "aws_s3_bucket_public_access_block" "block_public_access" {

0 commit comments

Comments
 (0)