Skip to content

Commit 8836925

Browse files
committed
feat: add lifecycle rule to expire logs
1 parent 9ca5eb2 commit 8836925

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ Each example generates a valid _jx-requirements.yml_ file that can be used to bo
462462
| <a name="input_enable_reports_storage"></a> [enable\_reports\_storage](#input\_enable\_reports\_storage) | Flag to enable or disable long term storage for reports | `bool` | `true` | no |
463463
| <a name="input_enable_repository_storage"></a> [enable\_repository\_storage](#input\_enable\_repository\_storage) | Flag to enable or disable the repository bucket storage | `bool` | `true` | no |
464464
| <a name="input_enable_tls"></a> [enable\_tls](#input\_enable\_tls) | Flag to enable TLS in the final `jx-requirements.yml` file | `bool` | `false` | no |
465+
| <a name="input_expire_logs_after_days"></a> [expire\_logs\_after\_days](#input\_expire\_logs\_after\_days) | Number of days objects in the logs bucket are stored | `number` | `90` | no |
465466
| <a name="input_force_destroy"></a> [force\_destroy](#input\_force\_destroy) | Flag to determine whether storage buckets get forcefully destroyed. If set to false, empty the bucket first in the aws s3 console, else terraform destroy will fail with BucketNotEmpty error | `bool` | `false` | no |
466467
| <a name="input_force_destroy_subdomain"></a> [force\_destroy\_subdomain](#input\_force\_destroy\_subdomain) | Flag to determine whether subdomain zone get forcefully destroyed. If set to false, empty the sub domain first in the aws Route 53 console, else terraform destroy will fail with HostedZoneNotEmpty error | `bool` | `false` | no |
467468
| <a name="input_ignoreLoadBalancer"></a> [ignoreLoadBalancer](#input\_ignoreLoadBalancer) | Flag to specify if jx boot will ignore loadbalancer DNS to resolve to an IP | `bool` | `false` | no |

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ module "cluster" {
5454
local-exec-interpreter = var.local-exec-interpreter
5555
profile = var.profile
5656
enable_logs_storage = var.enable_logs_storage
57+
expire_logs_after_days = var.expire_logs_after_days
5758
enable_reports_storage = var.enable_reports_storage
5859
enable_repository_storage = var.enable_repository_storage
5960
boot_secrets = var.boot_secrets

modules/cluster/storage.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ resource "aws_s3_bucket_lifecycle_configuration" "logs_jenkins_x" {
5454
days_after_initiation = 7
5555
}
5656
}
57+
rule {
58+
status = "Enabled"
59+
id = "delete_old"
60+
expiration {
61+
expired_object_delete_marker = false
62+
days = var.expire_logs_after_days
63+
}
64+
}
5765
}
5866

5967
// ---------------------------------

modules/cluster/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ variable "enable_logs_storage" {
2121
default = true
2222
}
2323

24+
variable "expire_logs_after_day" {
25+
description = "Number of days objects in the logs bucket are stored"
26+
type = number
27+
default = 90
28+
}
29+
2430
variable "enable_worker_group" {
2531
description = "Flag to enable worker group. Setting this to false will provision a node group instead"
2632
type = bool

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ variable "enable_logs_storage" {
9797
default = true
9898
}
9999

100+
variable "expire_logs_after_days" {
101+
description = "Number of days objects in the logs bucket are stored"
102+
type = number
103+
default = 90
104+
}
105+
100106
variable "enable_reports_storage" {
101107
description = "Flag to enable or disable long term storage for reports"
102108
type = bool

0 commit comments

Comments
 (0)