/**
SAGEMAKER NOTEBOOK - VARIABLES
**/

variable "environment" {
  description = "Available values: dev, qa, prod."
  type        = string
  default     = "dev"
}

variable "service_name" {
  description = "Name of the service/person that will benefit from this notebook instance"
  type        = string
}

variable "application_family" {
  description = "Name of application family that is related to this notebook instance"
  type        = string
}

variable "instance_name" {
  description = "The name of the notebook instance (must be unique)"
  type        = string
}

variable "instance_type" {
  description = "The name of ML compute instance type"
  type        = string
}

variable "priviate_subet_tags" {
  description = "The private subnet tags. This is the subnet that will contain the notebook instance"
  type        = string
  default     = "private0*"
}

variable "volume_size" {
  description = "The size, in GB, of the ML storage volume to attach to the notebook instance"
  type        = number
  default     = 5
}

variable "platform_identifier" {
  description = "The platform identifier of the notebook instance runtime environment"
  type        = string
  default     = "notebook-al2-v1"
}


variable "service_bucket" {
  description = "Bucket to use for the service"
  type        = string
  default     = "dev-cucumbers"
}

variable "code_repository_secret_arn" {
  description = "Name of the secret"
  type        = string
  default     = "arn:aws:secretsmanager:us-east-1:103233932089:secret:dev/sagemaker-notebook-instance/GITHUB_PASSWORD-BqhR8n"
}

variable "snowflake_secret_arn" {
  description = "Snowflake secret for secrets manager to create."
  type        = string
  default     = "arn:aws:secretsmanager:us-east-1:103233932089:secret:dev/sagemaker-notebook-instance/SNOWFLAKE_PASSWORD-gvImRH"
}

variable "default_code_repository_name" {
  description = "The URL where the Git repository is located"
  type        = string
  default     = "collab-repository"
}

variable "lifecycle_config_enabled" {
  description = "If lifecycle configuration will be associated with the notebook instance"
  type        = bool
  default     = false
}

variable "snowflake_password_required" {
  description = "If notebook instance should get access to Snowflake via secret"
  type        = bool
  default     = false
}

variable "https_listener_port" {
  description = "Port for HTTPS listener."
  type        = string
  default     = "443"
}

variable "dev_https_listener_allow_cidr_blocks" {
  description = "CIDR blocks from which to allow HTTPS for dev environments"
  type        = list(string)

  default = [
    "10.30.0.0/22",
    "10.40.0.0/22",
    "192.168.32.0/24",
    "192.168.33.0/24",
    "192.168.40.0/22",
  ]
}

variable "lifecyle_script_path" {
  description = "Path to the on-start.sh  file"
  type        = string
  default     = "./on-start.sh"
}

variable "https_listener_public_allow_cidr_blocks" {
  description = "CIDR blocks from which to allow HTTPS for public services"
  type        = list(string)
  default     = []
}

locals {
  https_listener_allow_cidr_blocks = {
    dev = concat(
      var.dev_https_listener_allow_cidr_blocks,
      var.https_listener_public_allow_cidr_blocks,
    )
  }
}


variable "additional_tags" {
  type        = map(string)
  description = "Optional map of additional tags to set on resources. These will be combined with programmatically set mandatory tags."
  default     = {}
}

# Concatenate required and user-supplied tags
locals {
  combined_resource_tags = merge(
    {
      environment        = var.environment
      service_name       = var.service_name
      application_family = var.application_family
      terraformed        = true
    },
    var.additional_tags
  )
}
