Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
2.5 kB
4
Indexable
Never
  // At least one window is requried when maintenance_polic block is provided. that's why we need dynamic on "maintenance_policy" block
  dynamic "maintenance_policy" {

    for_each = var.maintenance_start_time == "" && length(var.maintenance_exlusion_windows) == 0 ? [] : [1]
    content {

      dynamic "daily_maintenance_window" {
        for_each = var.maintenance_recurrence == "" && var.maintenance_end_time == "" && var.maintenance_start_time != "" ? [1] : []
        content {
          start_time = var.maintenance_start_time
        }
      }

      dynamic "recurring_window" {
        for_each = var.maintenance_recurrence != "" && var.maintenance_end_time != "" && var.maintenance_start_time != "" ? [1] : []
        content {
          start_time = var.maintenance_start_time
          end_time   = var.maintenance_end_time
          recurrence = var.maintenance_recurrence
        }
      }

      dynamic "maintenance_exclusion" {
        for_each = var.maintenance_exlusion_windows
        iterator = recurring
        content {
          exclusion_name = recurring.value.exlusion_name
          start_time     = recurring.value.start_time
          end_time       = recurring.value.end_time

          // We want to provide scope of exlusion
          exclusion_options {
            scope = recurring.value.scope
          }
        }
      }
    }
  }
}



variable "maintenance_end_time" {
  type        = string
  description = "End time of recurring windows maintenance - RFC3339 format. Provide this variable along with maintenance_recurrence variable to create recurring maintance window"
  default     = ""
}

variable "maintenance_recurrence" {
  type        = string
  description = "Frequency specififed for requrring maintenance window in RFC5545 format. Provide this variable along with maintenance_end_time to create recurring maintance window"
  default     = ""
}

variable "maintenance_start_time" {
  type        = string
  description = "For daily use 24-hour timestamp in UTC, for recurring maintanenace operations use RFC3339 fomrat"
  default     = ""

}

variable "maintenance_exlusion_windows" {
  type = list(object({
    /**
     *    exlusion_name = Name of exlusion
     *    start_time = RFC3339 FORMAT
     *    end_time = RFC3339 FORMAT
     *    format = One of NO_UPGRADES | NO_MINOR_UPGRADES | NO_MINOR_OR_NODE_UPGRADES
    */
    exlusion_name = string
    start_time    = string
    end_time      = string
    scope         = string
  }))
  default = []
}