variable "aws_region" {
  type        = string
  default     = "eu-central-1"
  description = "The AWS region to create the repository in"
}

variable "environment" {
  description = "The name of the environment"
  default     = "prod"
}

variable "account_group" {
  description = "The name of the application family"
  default     = "eom"
}

variable "prefix_list_share_regions" {
  description = "The regions to share the prefix list to"
  type        = set(string)
  default     = ["eu-central-1", "us-east-1"]
}

variable "application_family" {
  description = "Name of application family"
  default     = "devops"
}

variable "team_name" {
  description = "Name of the team that owns this infrastructure"
  default     = "devops"
}

variable "vpc_id" {
  default = "vpc-0630c375cbb0cacf4" # DIGSYS-P3 vpc
}

variable "vpc_name" {
  description = "Unique identifier for the VPC"
  default     = "digsys-p3"
}

variable "vpc_tgw_name" {
  description = "Unique identifier for the VPC in TGW"
  default     = "eom-prod-digsys-p3"
}

variable "xapp_subnet_ids" {
  default = [
    "subnet-0d7ea25a137ae4533", # DIGSYS-P3-XAPP-1A
    "subnet-09667b0f50e7c0c10", # DIGSYS-P3-XAPP-1B
    "subnet-07782ebc5126df96f", # DIGSYS-P3-XAPP-1C
  ]
}

variable "route_table_id" {
  default = "rtb-0045a0e5dafe59b52" # DIGSYS-P3-APP-RT
}

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
  ]
}

variable "vpc_routing_destination_prefix_lists" {
  type        = list(string)
  description = "list of prefix lists names that should be routable from the private subnets"
  default = [
    "shared-orcd-atlantis-private-subnet-prefix-list",
  ]
}

variable "vpc_routing_destination_cidr_blocks" {
  type        = list(string)
  description = "list of CIDR blocks that should be routable from the selected subnets"
  default     = []
}

locals {
  pl_internal_routes = [
    for tuple in setproduct(toset([var.route_table_id]), toset(data.aws_ec2_managed_prefix_lists.required_routes.ids)) : {
      route_table_id = tuple[0]
      prefix_list_id = tuple[1]
    }
  ]
  cidr_internal_routes = [
    for tuple in setproduct(toset([var.route_table_id]), toset(var.vpc_routing_destination_cidr_blocks)) : {
      route_table_id = tuple[0]
      cidr           = tuple[1]
    }
  ]
}
