Skip to content

Commit

Permalink
Merge pull request #43 from sparkfabrik/versioning_lifecycle
Browse files Browse the repository at this point in the history
refs platform/1764: versioning lifecycle
  • Loading branch information
Syphon83 authored Nov 25, 2022
2 parents 7a77978 + 724b72f commit b80ad50
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ Then perform the following commands on the root folder:
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| certmanager\_email | Email used to retrieve SSL certificates from Let's Encrypt | `string` | n/a | yes |
| cloud\_nat\_log\_config\_enable | Indicates whether or not to export logs. | `bool` | `false` | no |
| cloud\_nat\_log\_config\_filter | Specifies the desired filtering of logs on this NAT. Valid values are: 'ERRORS\_ONLY', 'TRANSLATIONS\_ONLY', 'ALL'. | `string` | `"ALL"` | no |
| cloud\_nat\_min\_ports\_per\_vm | Minimum number of ports allocated to a VM from this NAT config. | `string` | `"64"` | no |
| domain | Domain for hosting gitlab functionality (ie mydomain.com would access gitlab at gitlab.mydomain.com) | `string` | `""` | no |
| gcp\_existing\_db\_secret\_name | Setup the GCP secret name where to retrieve the password value that will be used for postgres DB. In case an empty string is passed,a random value will be filled in a default gcp secret named gitlab-db-password | `string` | `""` | no |
| gcp\_existing\_omniauth\_secret\_name | Only if Omniauth is enabled. Setup the GCP secret name where to retrieve the configuration that will be used for Omniauth Configuration. | `string` | `""` | no |
Expand All @@ -42,8 +45,10 @@ Then perform the following commands on the root folder:
| gcs\_bucket\_allow\_force\_destroy | Allows full cleanup of buckets by disabling any deletion safe guards | `bool` | `false` | no |
| gcs\_bucket\_backup\_duration | When the backup lifecycle is enabled, set the number of days after which the backup files are deleted | `number` | `120` | no |
| gcs\_bucket\_enable\_backup\_lifecycle\_rule | Enable lifecycle rule for backup bucket | `bool` | `false` | no |
| gcs\_bucket\_num\_newer\_version | When the bucket versioning is enabled, Delete noncurrent versions of objects if there are X newer versions of the object in the bucket. Objects subject to this rule are permanently deleted and cannot be recovered. | `number` | `2` | no |
| gcs\_bucket\_storage\_class | Bucket storage class. Supported values include: STANDARD, MULTI\_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE | `string` | `"STANDARD"` | no |
| gcs\_bucket\_target\_storage\_class | The target Storage Class of objects affected by this Lifecycle Rule. Supported values include: STANDARD, MULTI\_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE. | `string` | `"COLDLINE"` | no |
| gcs\_bucket\_versioned\_files\_duration | When the bucket versioning is enabled, Delete noncurrent versions of objects after they've been noncurrent for X days. Objects subject to this rule are permanently deleted and cannot be recovered. | `number` | `120` | no |
| gcs\_bucket\_versioning | Setup Object Storage versioning for all Bucket created. | `bool` | `true` | no |
| gitab\_enable\_migrations | Enable migrations sub chart | `bool` | `true` | no |
| gitab\_enable\_prom\_exporter | Enable gitlab prometheus exporter | `bool` | `false` | no |
Expand Down Expand Up @@ -102,7 +107,8 @@ Then perform the following commands on the root folder:
| gke\_sc\_gitlab\_backup\_disk | Storage class for Perstistent Volume used for extra space in Backup Cron Job . Default pd-sdd. | `string` | `"standard"` | no |
| gke\_sc\_gitlab\_restore\_disk | Storage class for Perstistent Volume used for extra space in Backup Restore Job. Default pd-sdd. | `string` | `"standard"` | no |
| gke\_services\_subnet\_cidr | Cidr range to use for gitlab GKE services subnet | `string` | `"10.20.0.0/16"` | no |
| gke\_storage\_class | Default storage class for GKE Cluster. Default pd-sdd. | `string` | `"pd-ssd"` | no |
| gke\_storage\_class | Default storage class for GKE Cluster. Default pd-sdd | `string` | `"pd-ssd"` | no |
| gke\_storage\_class\_reclaim\_policy | Set storage class reclaim policy. Default Retain | `string` | `"Retain"` | no |
| gke\_version | Version of GKE to use for the GitLab cluster | `string` | `"latest"` | no |
| helm\_chart\_version | Helm chart version to install during deployment - Default Gitlab 14.9.3 | `string` | `"5.9.3"` | no |
| postgresql\_availability\_type | The availability type of the Cloud SQL instance, high availability (REGIONAL) or single zone (ZONAL). | `string` | `"REGIONAL"` | no |
Expand Down
23 changes: 22 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,28 @@ resource "google_storage_bucket" "gitlab_bucket" {
versioning {
enabled = var.gcs_bucket_versioning
}

dynamic "lifecycle_rule" {
for_each = var.gcs_bucket_versioning == true ? [1] : []
content {
action {
type = "Delete"
}
condition {
num_newer_versions = var.gcs_bucket_num_newer_version
}
}
}
dynamic "lifecycle_rule" {
for_each = var.gcs_bucket_versioning == true ? [1] : []
content {
action {
type = "Delete"
}
condition {
days_since_noncurrent_time = var.gcs_bucket_versioned_files_duration
}
}
}
dynamic "lifecycle_rule" {
for_each = var.gcs_bucket_enable_backup_lifecycle_rule == true && each.value == "backups" ? [1] : []
content {
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ variable "gcs_bucket_backup_duration" {
default = 120
}

variable "gcs_bucket_versioned_files_duration" {
type = number
description = "When the bucket versioning is enabled, Delete noncurrent versions of objects after they've been noncurrent for X days. Objects subject to this rule are permanently deleted and cannot be recovered."
default = 120
}

variable "gcs_bucket_num_newer_version" {
type = number
description = "When the bucket versioning is enabled, Delete noncurrent versions of objects if there are X newer versions of the object in the bucket. Objects subject to this rule are permanently deleted and cannot be recovered."
default = 2
}

##################
# GKE SECTION #
##################
Expand Down

0 comments on commit b80ad50

Please sign in to comment.