variable "name" {
  description = "Name prefix applied to the VPC and all child resources (via the Name tag)."
  type        = string

  validation {
    condition     = length(var.name) > 0 && length(var.name) <= 100
    error_message = "name must be between 1 and 100 characters."
  }
}

variable "cidr_block" {
  description = "IPv4 CIDR block for the VPC."
  type        = string
  default     = "10.0.0.0/16"

  validation {
    condition     = can(cidrnetmask(var.cidr_block))
    error_message = "cidr_block must be a valid IPv4 CIDR, e.g. 10.0.0.0/16."
  }
}

variable "azs" {
  description = "Availability zones to spread subnets across. Subnet N lands in AZ N."
  type        = list(string)

  validation {
    condition     = length(var.azs) > 0
    error_message = "Provide at least one availability zone."
  }
}

variable "public_subnet_cidrs" {
  description = "CIDR blocks for public subnets. One subnet is created per entry, paired with the AZ at the same index."
  type        = list(string)
  default     = []

  validation {
    condition     = alltrue([for c in var.public_subnet_cidrs : can(cidrnetmask(c))])
    error_message = "Every public subnet CIDR must be a valid IPv4 CIDR."
  }
}

variable "private_subnet_cidrs" {
  description = "CIDR blocks for private subnets. One subnet is created per entry, paired with the AZ at the same index."
  type        = list(string)
  default     = []

  validation {
    condition     = alltrue([for c in var.private_subnet_cidrs : can(cidrnetmask(c))])
    error_message = "Every private subnet CIDR must be a valid IPv4 CIDR."
  }
}

variable "enable_dns_support" {
  description = "Enable DNS resolution in the VPC."
  type        = bool
  default     = true
}

variable "enable_dns_hostnames" {
  description = "Assign DNS hostnames to instances with public IPs."
  type        = bool
  default     = true
}

variable "enable_nat_gateway" {
  description = "Provision NAT gateway(s) so private subnets can reach the internet outbound."
  type        = bool
  default     = true
}

variable "single_nat_gateway" {
  description = "Use one shared NAT gateway instead of one per AZ. Cheaper, but a single-AZ failure domain for egress."
  type        = bool
  default     = true
}

variable "tags" {
  description = "Tags applied to every resource the module creates."
  type        = map(string)
  default     = {}
}
