variable "aws_region" {
  description = "AWS region to launch servers."
  default     = "us-east-1"
}

variable "environment" {
  description = "Which environment this is running in"
  default     = "dev"
  type        = string
}

variable "aws_stack_name" {
  description = "Stack name, will be used as DNS prefix, e.g. jenkins-chef"
  type        = string
}

variable "vpc_id" {
  description = "ID of existing vpc"
  default     = "vpc-34dbfd51"
}

variable "vpc_ssh_group" {
  description = "Name of security group to allow ssh"
  default     = "vpn_ssh"
}

variable "vpc_private_subnet_ids" {
  description = "IDs for private subnets in VPC"
  type        = list(string)
}

variable "vpc_elb_subnet_ids" {
  description = "Subnet IDs for ELB"
  type        = list(string)
}

variable "az" {
  description = "Availability zone for EBS volume"
  default     = "us-east-1b"
}

variable "aws_device_label" {
  description = "Device label for /var/lib/jenkins"
  default     = "/dev/nvme1n1"
}

variable "aws_device_name" {
  description = "Device name for attaching"
  default     = "/dev/sdf"
}

variable "aws_device_size" {
  description = "Attached disk size"
  default     = "10"
}

variable "aws_instance_type" {
  description = "AWS instance type"
  default     = "m4.large"
}

# Volume type for jenkins ebs
variable "aws_ebs_volume_type" {
  default = "gp3"
}

variable "aws_key_name" {
  description = "Desired name of AWS key pair"
  default     = "orcd-dev"
}

variable "user_data" {
  description = "User data script"
  default     = ""
}


variable "aws_elb_access_ips" {
  description = "CIDR block for ELB ingress SG"
  type        = list(string)
}

variable "elb_logging_bucket" {
  description = "S3 bucket to send ELB logs"
  default     = "orch-elb-logs"
}

variable "https_listener_ssl_policy" {
  description = "HTTPS listener SSL policy"
  default     = "ELBSecurityPolicy-TLS-1-2-2017-01"
}

variable "override_route53_zone_id" {
  description = "AWS Route 53 zone id to override the default zone id"
  default     = null
}



variable "route53_record_ttl" {
  description = "TTL associated with Route53 CNAME record"
  default     = "60"
}

variable "environment" {
  description = "Environment (dev, qa, prod)"
  default     = "prod"
}

variable "ssh_cli_port" {
  description = "SSH port for master's internal ssh server"
  default     = "34228"
}

variable "asg_suspended_processes" {
  description = "List of processes to suspend for the Auto Scaling Group."
  type        = list(string)
  default     = []
}

variable "lb_source_sg_access" {
  type    = list(string)
  default = []
}

locals {
  default_user_data = templatefile("${path.module}/jenkins_controller_user_data.tpl", {
    volume_id  = aws_ebs_volume.ebs.id
    aws_region = var.aws_region
    device     = var.aws_device_label
    aws_device = var.aws_device_name
  })
  combined_user_data = base64encode("${local.default_user_data}\n${var.user_data}")
  # Determine Route53 zone ID based on environment unless overridden
  route53_zone_id = var.override_route53_zone_id != null ? var.override_route53_zone_id : (var.route53_zone_id != null ? var.route53_zone_id : (var.environment == "dev" ? "Z21XEY26C989RH" : "Z0183645HDT0XCWHLW7S"))
}
