Skip to content

Commit

Permalink
feat: add lifecycle rule to expire logs
Browse files Browse the repository at this point in the history
  • Loading branch information
msvticket committed Oct 8, 2024
1 parent 9ca5eb2 commit 8836925
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ Each example generates a valid _jx-requirements.yml_ file that can be used to bo
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module "cluster" {
local-exec-interpreter = var.local-exec-interpreter
profile = var.profile
enable_logs_storage = var.enable_logs_storage
expire_logs_after_days = var.expire_logs_after_days
enable_reports_storage = var.enable_reports_storage
enable_repository_storage = var.enable_repository_storage
boot_secrets = var.boot_secrets
Expand Down
8 changes: 8 additions & 0 deletions modules/cluster/storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ resource "aws_s3_bucket_lifecycle_configuration" "logs_jenkins_x" {
days_after_initiation = 7
}
}
rule {
status = "Enabled"
id = "delete_old"
expiration {
expired_object_delete_marker = false
days = var.expire_logs_after_days
}
}
}

// ---------------------------------
Expand Down
6 changes: 6 additions & 0 deletions modules/cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ variable "enable_logs_storage" {
default = true
}

variable "expire_logs_after_day" {
description = "Number of days objects in the logs bucket are stored"
type = number
default = 90
}

variable "enable_worker_group" {
description = "Flag to enable worker group. Setting this to false will provision a node group instead"
type = bool
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ variable "enable_logs_storage" {
default = true
}

variable "expire_logs_after_days" {
description = "Number of days objects in the logs bucket are stored"
type = number
default = 90
}

variable "enable_reports_storage" {
description = "Flag to enable or disable long term storage for reports"
type = bool
Expand Down

0 comments on commit 8836925

Please sign in to comment.