variable "env" {
  type        = string
  default     = "dev"
  description = "The environment for the RDS instance, e.g., dev, staging, prod"
}
variable "region" {
  type        = string
  default     = "us-west-2"
  description = "The AWS region to deploy RDS in"
}

variable "name" {
  type        = string
  description = "The name suffix of the RDS instance"
}

variable "publicly_accessible" {
  type        = bool
  default     = true
  description = "Whether the RDS instance should be publicly accessible"
}

variable "managed_secret" {
  type        = bool
  default     = false
  description = "Whether to use AWS RDS to manage the RDS instance password"
}

variable "public_access_cidrs" {
  type    = list(string)
  default = ["0.0.0.0/0"]
}

variable "vpc" {
  type = object({
    cidr               = optional(string, "192.168.0.0/16") // The CIDR block for the VPC
    availability_zones = optional(string, null)             // A comma-separated list of availability zones to use for the VPC
  })
}
variable "db" {
  type = object({
    instance_class    = optional(string, "db.t3.micro")  // The instance class for the RDS instance
    instance_count    = optional(number, 1)              // The number of RDS instances to create
    engine            = optional(string, "aurora-mysql") // The database engine to use for the RDS instance, e.g., aurora-mysql, aurora-postgres
    engine_version    = optional(string, null)           // The version of the database engine
    storage_type      = optional(string, null)           // The storage type for the RDS instance, e.g., gp2, io1
    allocated_storage = optional(number, null)           // The allocated storage in GB for the RDS instance
    storage_encrypted = optional(bool, true)             // Whether the RDS instance storage should be encrypted
    default_db_name   = optional(string, "mydb")         // The default database name to create on the RDS instance
    port              = optional(number, 3306)           // The port on which the RDS instance will listen
    admin_user        = optional(string, "admin")        // The admin username for the RDS instance
  })
  description = "The configuration for the RDS instance"
}

variable "cluster_params" {
  type = map(string)
  default = {
  }
}

variable "tags" {
  type        = map(string)
  default     = {}
  description = "Tags to apply to all resources"
}

variable "privatelink_type" {
  type        = string
  default     = "auto"
  description = "PrivateLink type"

  validation {
    condition     = contains(["auto", "rds-proxy", "resource-gateway"], var.privatelink_type)
    error_message = "PrivateLink type must be one of: auto, rds-proxy, resource-gateway."
  }
}
