##################### COMMON VARIABLES #######################
variable "account_name" {
  description = "Name of the AWS account"
  type        = string
  default     = "sme-digital-systems-dev"
}

variable "account_id" {
  description = "AWS Account Number of sme-digital-systems-dev"
  type        = string
  default     = "718729873097"
}

variable "region" {
  description = "Name of the region"
  type        = string
  default     = "eu-central-1"
}

variable "assume_role" {
  description = "The role used for infra changes"
  type        = string
  default     = "arn:aws:iam::718729873097:role/AnsibleAWSServiceAccess-DIGSYS-D3"
}

variable "tags" {
  description = "A map of tags to add to all resources"
  type        = map(string)

  default = {
    Terraform     = "True"
    Business-Unit = "DIGITAL SYSTEMS"
    Environment   = "Dev"
    Name          = "DIGSYS-D3"
    Owner         = "steve.leeds@sonymusic.com"
    Project-Code  = "SME-2000-0590D+M"
    Project-Name  = "Digital Systems"
    POC           = "steve.leeds@sonymusic.com"
    aws-migration-project-id = "MPE22602"
    map-migrated = "d-server-02sa4nzuab143a"
  }
}

variable "https_port" {
  description = "HTTPS Port"
  type        = number
  default     = 443
}

variable "host_header" {
  description = "Host Header"
  type        = string
  default     = "digsys-dev.smecloudops.com"
}

##################### SECURITY GROUPS VARIABLES #######################

variable "sg_use_name_prefix" {
  description = "To use SG prefix"
  type        = bool
  default     = false
}

##################### VPC VARIABLES #######################

variable "vpc_name" {
  description = "VPC Name"
  type        = string
  default     = "DIGSYS-D3"
}

variable "vpc_cidr" {
  description = "Primary VPC CIDR"
  type        = string
  default     = "10.250.242.0/24"
}

variable "vpc_id" {
  type    = string
  default = "vpc-081a4216f852f621b"
}

variable "secondary_cidr_blocks" {
  description = "Secondary CIDR blocks"
  type        = list(string)
  default     = ["10.250.6.0/24", "10.249.10.48/28", "10.11.188.0/25"]
}

variable "public_subnets" {
  description = "Public Subnets"
  type        = list(string)
  default     = ["10.250.242.0/27", "10.250.242.32/27", "10.249.10.48/28"]
}

variable "private_subnets" {
  description = "Private Subnets"
  type        = list(string)
  default     = ["10.250.242.128/26", "10.250.242.192/26", "10.250.242.96/27", "10.11.188.0/26", "10.11.188.64/26"]
}

variable "database_subnets" {
  description = "Database Subnets"
  type        = list(string)
  default     = ["10.250.242.64/28", "10.250.242.80/28"]
}

variable "intra_subnets" {
  description = "Intra Subnets"
  type        = list(string)
  default     = ["10.250.6.0/25", "10.250.6.128/25"]
}

variable "emr_subnets" {
  description = "Elastic cache Subnets"
  type        = list(string)
  default     = []
}

variable "create_redshift_subnet_group" {
  description = "To create redshift subnet group"
  type        = bool
  default     = false
}

variable "dhcp_domain_name_servers" {
  description = "DNS IPS"
  type        = list(string)
  default     = ["162.49.203.44", "10.250.197.130"]
}

variable "local_s3_arn" {
  description = "Flow logs stored in same account S3 bucket"
  type        = string
  default     = "arn:aws:s3:::sme-digital-systems-dev-eu-central-1-s3-logs"
}

variable "centralised_s3_arn" {
  description = "Flow logs stored in centralised account S3 bucket"
  type        = string
  default     = "arn:aws:s3:::sme-core-cloud-compliance-centralised-vpc-flowlogs"
}

variable "enable_dhcp_options" {
  description = "To enable DHCP options for VPC"
  type        = bool
  default     = true
}

variable "flow_log_max_aggregation_interval" {
  description = "VPC Flow logs interval"
  type        = number
  default     = 600
}

variable "flow_log_cloudwatch_iam_role_arn" {
  description = "IAM role ARN for flow logs"
  type        = string
  default     = "arn:aws:iam::718729873097:role/flowlogsRole"
}

variable "route_zone" {
  description = "Route53 zone name for this VPC"
  type        = string
  default     = "smedigsysd"
}

variable "instance_tenancy" {
  description = "Instance Tenancy for this VPC"
  type        = string
  default     = "default"
}

variable "enable_network_address_usage_metrics" {
  description = "enable_network_address_usage_metrics"
  type        = bool
  default     = false
}

variable "enable_dns_support" {
  description = "enable_dns_support"
  type        = bool
  default     = true
}

variable "enable_dns_hostnames" {
  description = "enable_dns_hostnames"
  type        = bool
  default     = true
}

variable "assign_generated_ipv6_cidr_block" {
  description = "assign_generated_ipv6_cidr_block"
  type        = bool
  default     = false
}

variable "assign_ipv6_address_on_creation" {
  description = "assign_ipv6_address_on_creation"
  type        = bool
  default     = false
}

variable "enable_dns64" {
  description = "enable_dns64"
  type        = bool
  default     = false
}

variable "enable_resource_name_dns_a_record_on_launch" {
  description = "enable_resource_name_dns_a_record_on_launch"
  type        = bool
  default     = false
}

variable "enable_resource_name_dns_aaaa_record_on_launch" {
  description = "enable_resource_name_dns_aaaa_record_on_launch"
  type        = bool
  default     = false
}

variable "ipv6_native" {
  description = "ipv6_native"
  type        = bool
  default     = false
}

variable "map_public_ip_on_launch" {
  description = "ipv6_native"
  type        = bool
  default     = false
}

variable "private_dns_hostname_type_on_launch" {
  description = "private_dns_hostname_type_on_launch"
  type        = string
  default     = "ip-name"
}

##################### EC2 VARIABLES #######################

variable "default_ami" {
  description = "AMI to use for all instances"
  type        = string
  default     = "ami-04949fe15ac570674"
}

variable "instance_type" {
  description = "Default instance type to use"
  type        = string
  default     = "t3.medium"
}

variable "ssh_key_name" {
  description = "Default instance Key to use"
  type        = string
  default     = "digital-systems-d-05MAR2024"
}

variable "ec2_monitoring" {
  description = "EC2 Monitoring"
  type        = bool
  default     = false
}

variable "disable_api_termination" {
  description = "EC2 termination protection"
  type        = bool
  default     = true
}

variable "ec2_tags" {
  description = "A map of tags to add to all resources"
  type        = map(string)

  default = {
    CLOPS_APPROVED : "True"
    Terraform = "True"
    Business-Unit = "DIGITAL SYSTEMS"
    Environment   = "DEV"
    Name          = "DIGSYS-D3"
    Owner         = "steve.leeds@sonymusic.com"
    Project-Code  = "SME-2000-0590D+M"
    Project-Name  = "Digital Systems"
    POC = "steve.leeds@sonymusic.com"
    OS = "AL3"
    SERVER_TYPE = "EC2"
    OPS = "STND"
    DATA = "NORMAL"
    Patch_Group = "General"
    aws-migration-project-id = "MPE22602"
    map-migrated = "d-server-02sa4nzuab143a"
  }
}

variable "cloudops_firewall_protected_tag" {
  description = "Used to tag an EC2 instance as being protected by a firewall, either Network Firewall or PaloAlto"
  type        = map(string)

  default = {
    CLOPS_FW = "YES"
  }
}

##################### ALB VARIABLES #######################

variable "internal" {
  description = "ALB type"
  type        = bool
  default     = true
}

variable "enable_deletion_protection" {
  description = "ALB deletion protection"
  type        = bool
  default     = true
}

variable "enable_waf_fail_open" {
  description = "ALB WAF"
  type        = bool
  default     = true
}

variable "drop_invalid_header_fields" {
  description = "ALB drop invalid headers"
  type        = bool
  default     = true
}

variable "alb_certificate_arn" {
  description = "ALB listener certificate ARN"
  type        = string
  default     = ""
}

variable "alb_ssl_policy" {
  description = "ALB Security Policy"
  type        = string
  default     = "ELBSecurityPolicy-TLS13-1-2-2021-06"
}

variable "alb_logs_bucket" {
  description = "ALB logs bucket"
  type        = string
  default     = "digital-systems-dev-frankfurt-elb-logs"
}

##################### EFS VARIABLES #######################

variable "posix_uid" {
  description = "POSIX user ID"
  type        = number
  default     = 1184
}

variable "posix_gid" {
  description = "POSIX group ID"
  type        = number
  default     = 2006
}

variable "posix_permissions" {
  description = "POSIX permissions"
  type        = number
  default     = 755
}

##################### EKS VARIABLES #####################

variable "cluster_name" {
  type    = string
  default = "digsysd3-eks-eks"
}

variable "cluster_version" {
  type    = string
  default = "1.30"
}

variable "cluster_subnet_ids" {
  type    = list(any)
  default = ["subnet-03481e6ad6f1ebbc3", "subnet-033e49093c99cd688"]
}


variable "cluster_ingress_rules" {
  type = list(any)
  default = [
    {
      from_port       = 0
      to_port         = 65535
      description     = "DIGSYS-D3 VPC"
      protocol        = "tcp"
      cidr_blocks     = ["10.250.242.0/24", "10.11.188.0/25", "10.250.6.0/24"]
      self            = false
      security_groups = []
    },
    {
      from_port       = 0
      to_port         = 65535
      description     = "DIGSYS-D3 VPC"
      protocol        = "udp"
      cidr_blocks     = ["10.250.242.0/24", "10.11.188.0/25", "10.250.6.0/24"]
      self            = false
      security_groups = []
    },
    {
      from_port       = 80
      to_port         = 80
      description     = "HTTPS"
      protocol        = "tcp"
      cidr_blocks     = ["0.0.0.0/0"]
      self            = false
      security_groups = []
    },
    {
      from_port       = 443
      to_port         = 443
      description     = "HTTPS"
      protocol        = "tcp"
      cidr_blocks     = ["0.0.0.0/0"]
      self            = false
      security_groups = []
    }
  ]
}

variable "cluster_egress_rules" {
  type = list(any)
  default = [
    {
      from_port       = 0
      to_port         = 65535
      description     = "DIGSYS-D3 VPC"
      protocol        = "tcp"
      cidr_blocks     = ["10.250.242.0/24", "10.11.188.0/25", "10.250.6.0/24"]
      self            = false
      security_groups = []
    },
    {
      from_port       = 0
      to_port         = 65535
      description     = "DIGSYS-D3 VPC"
      protocol        = "udp"
      cidr_blocks     = ["10.250.242.0/24", "10.11.188.0/25", "10.250.6.0/24"]
      self            = false
      security_groups = []
    },
  ]
}

variable "aws_auth_roles" {
  type = list(any)
  default = [
    {
      rolearn  = "arn:aws:iam::476717493283:user/ccshr-eks-admin"
      username = "EKSAdmin"
      groups   = ["system:masters"]
    },
    {
      rolearn  = "arn:aws:iam::476717493283:user/clshrd-jenkins"
      username = "clshrd-jenkins"
      groups   = ["system:masters"]
    },
    {
      rolearn  = "arn:aws:iam::718729873097:user/digsysd-jenkins"
      username = "jenkins"
      groups   = ["system:masters"]
    },
    {
      rolearn  = "arn:aws:iam::718729873097:role/digsysd-drd-eks-developer"
      username = "digsysd-eks-user"
      groups   = ["system:masters"]
    }
  ]
}

variable "eni_config" {
  type = list(any)
  default = [
    {
      az       = "eu-central-1a",
      subnetid = "subnet-03481e6ad6f1ebbc3"
    },
    {
      az       = "eu-central-1b",
      subnetid = "subnet-033e49093c99cd688"
    }
  ]
}

##################### Launch Template VARIABLES #######################

variable "eks_ami" {
  type    = string
  default = "ami-04c83e4a5ddeeeba8"
}

variable "eks_instance_type" {
  type    = string
  default = "m5.xlarge"
}

variable "eks_ssh_key" {
  type    = string
  default = "eom-dev-ff"
}


##################### NodeGroup VARIABLES #######################

variable "add_nodegroup_iam_policies" {
  type    = bool
  default = false
}

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

variable "desired_size" {
  type    = number
  default = 2
}

variable "max_size" {
  type    = number
  default = 4
}

variable "min_size" {
  type    = number
  default = 2
}

##################### ASG LAUNCH TEMPLATE VARIABLES ###################

variable "launch_template_image_id" {
  type    = string
  default = "ami-075c2e868f8a75609"
}

variable "launch_template_instance_type" {
  type    = string
  default = "m5.xlarge"
}

variable "launch_template_key_name" {
  type    = string
  default = "eom-dev-ff"
}

##################### EKS NODE GROUP VARIABLES #######################

variable "node_group_role_arn" {
  type    = string
  default = "arn:aws:iam::718729873097:role/digsysd-EKS-worker-node-Role"
}

##################### EKS VARIABLES #######################

variable "enabled_cluster_log_types" {
  type    = list(string)
  default = ["api", "audit", "authenticator", "controllerManager", "scheduler"]
}

variable "eks_subnets" {
  type    = list(string)
  default = ["subnet-03481e6ad6f1ebbc3", "subnet-033e49093c99cd688"]
}

variable "worker_node_subnets" {
  type    = list(string)
  default = ["subnet-000d19dc9f0ef703f", "subnet-024ff3eeb07c92a41"]
}

variable "eks_version" {
  type    = string
  default = "1.29"
}

variable "eks_cluster_role_arn" {
  type    = string
  default = "arn:aws:iam::718729873097:role/digsysd-EKS-Service-Role"
}

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

variable "encryption_config_provider_key_arn" {
  type    = string
  default = "arn:aws:kms:eu-central-1:718729873097:key/3516687d-4d78-466f-b690-ad45c8603dd0"
}

variable "vpc_config_endpoint_private_access" {
  type    = bool
  default = true
}

variable "vpc_config_endpoint_public_access" {
  type    = bool
  default = false
}

variable "environment" {
  description = "Environment name"
  default     = "dev"
}

variable "account_group" {
  description = "The name of the account group that the account belongs to"
  default     = "eom"
}

variable "resource_share_principals" {
  type        = set(string)
  description = "List of principals to share resources with using RAM"
  default = [
    "arn:aws:organizations::970903126758:ou/o-bqioddgr91/ou-ax9e-vu43qt3i", # PDE+GO OU
  ]
}
