Skip to content

Commit 528ded0

Browse files
Merge pull request #37 from DNXLabs/feature/efs-lifecycle-policy
Enable use of EFS Lifecycle policy.
2 parents 6e65765 + 3107f18 commit 528ded0

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ module "ecs_apps" {
9595
| create\_efs | Enables creation of EFS volume for cluster | `bool` | `true` | no |
9696
| create\_iam\_service\_linked\_role | Create iam\_service\_linked\_role for ECS or not. | `bool` | `false` | no |
9797
| ec2\_key\_enabled | Generate a SSH private key and include in launch template of ECS nodes | `bool` | `false` | no |
98+
| efs\_lifecycle\_transition\_to\_ia | Option to enable EFS Lifecycle Transaction to IA | `string` | `""` | no |
99+
| efs\_lifecycle\_transition\_to\_primary\_storage\_class | Option to enable EFS Lifecycle Transaction to Primary Storage Class | `bool` | `false` | no |
98100
| enable\_schedule | Enables schedule to shut down and start up instances outside business hours. | `bool` | `false` | no |
99101
| extra\_certificate\_arns | Extra ACM certificates to add to ALB Listeners | `list(string)` | `[]` | no |
100102
| fargate\_only | Enable when cluster is only for fargate and does not require ASG/EC2/EFS infrastructure | `bool` | `false` | no |

_variables.tf

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,25 @@ variable "create_efs" {
323323
description = "Enables creation of EFS volume for cluster"
324324
}
325325

326-
327326
variable "asg_capacity_rebalance" {
328327
type = bool
329328
default = false
330329
description = "Indicates whether capacity rebalance is enabled"
331330
}
331+
332+
variable "efs_lifecycle_transition_to_ia" {
333+
type = string
334+
default = ""
335+
description = "Option to enable EFS Lifecycle Transaction to IA"
336+
337+
validation {
338+
condition = contains(["AFTER_7_DAYS", "AFTER_14_DAYS", "AFTER_30_DAYS", "AFTER_60_DAYS", "AFTER_90_DAYS", ""], var.efs_lifecycle_transition_to_ia)
339+
error_message = "Indicates how long it takes to transition files to the IA storage class. Valid values: AFTER_7_DAYS, AFTER_14_DAYS, AFTER_30_DAYS, AFTER_60_DAYS, AFTER_90_DAYS. Or leave empty if not used."
340+
}
341+
}
342+
343+
variable "efs_lifecycle_transition_to_primary_storage_class" {
344+
type = bool
345+
default = false
346+
description = "Option to enable EFS Lifecycle Transaction to Primary Storage Class"
347+
}

efs.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ resource "aws_efs_file_system" "ecs" {
77
throughput_mode = var.throughput_mode
88
provisioned_throughput_in_mibps = var.provisioned_throughput_in_mibps
99

10+
dynamic "lifecycle_policy" {
11+
for_each = var.efs_lifecycle_transition_to_ia != "" ? [1] : []
12+
content {
13+
transition_to_ia = var.efs_lifecycle_transition_to_ia
14+
}
15+
}
16+
17+
dynamic "lifecycle_policy" {
18+
for_each = var.efs_lifecycle_transition_to_primary_storage_class ? [1] : []
19+
content {
20+
transition_to_primary_storage_class = "AFTER_1_ACCESS"
21+
}
22+
}
23+
1024
tags = {
1125
Name = "ecs-${var.name}"
1226
Backup = var.backup

0 commit comments

Comments
 (0)