resource "aws_default_security_group" "MAX-U3-DEFAULT-SG" {
  vpc_id = aws_vpc.MAX-U3.id
  tags = merge(var.tags, {
    Name = "MAX-U3-DEFAULT-SG"
    Name = "MAX-U3-DEFAULT-SG"
  })
}

resource "aws_security_group" "MAX-U3-GSIRT-SG" {
  name        = "MAX-U3-GSIRT-SG"
  description = "MAX-U3-GSIRT-SG"
  egress = [
    {
      cidr_blocks      = ["10.250.92.0/24", "10.251.12.0/22", "10.11.107.0/26"]
      description      = "VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.251.12.0/22", "10.11.107.0/26"]
      description      = "VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    }
  ]
  ingress = [
    {
      cidr_blocks      = ["10.250.92.0/24", "10.251.12.0/22", "10.11.107.0/26"]
      description      = "GSIRT-TCP-8089"
      from_port        = 8089
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 8089
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.251.12.0/22", "10.11.107.0/26"]
      description      = "GSIRT-TCP-9998"
      from_port        = 9998
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9998
    },
  ]
  tags = merge(var.tags, {
    Name     = "MAX-U3-GSIRT-SG"
    CLOPS_FW = "NO"
  })
  vpc_id = aws_vpc.MAX-U3.id
}

resource "aws_security_group" "MAX-U3-BATCH-SG" {
  description = "MAX-U3-BATCH-SG"
  egress = [
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "HTTP"
      from_port        = 80
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 80
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "HTTPS"
      from_port        = 443
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 443
    },
    {
      cidr_blocks      = ["10.250.70.0/24", "10.11.187.0/25"]
      description      = "DIGSYS-S3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["10.250.70.0/24", "10.11.187.0/25"]
      description      = "DIGSYS-S3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.251.12.0/22", "10.11.107.0/26", "10.249.4.208/28"]
      description      = "MAX-U3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.251.12.0/22", "10.11.107.0/26", "10.249.4.208/28"]
      description      = "MAX-U3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["172.34.32.64/28", "172.34.12.0/25", "172.34.24.128/25", "172.32.6.0/24", "172.34.12.192/28"]
      description      = "MAX-FF-P"
      from_port        = 3306
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 3306
    }
  ]
  ingress = [
    {
      cidr_blocks      = ["10.11.176.219/32", "10.12.246.64/27", "10.250.2.64/27"]
      description      = "CloudOPS Bastions"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
  ]
  name = "MAX-U3-BATCH-SG"
  tags = {
    Environment    = "UAT"
    Name           = "MAX-U3-BATCH-SG"
    CLOPS_FW       = "YES"
    Terraform      = "TRUE"
    Business-Unit  = "SME-MAX"
    Owner          = "chris.mollis.objectlab@sonymusic.com"
    Project-Code   = "SME-2000-0590E"
    Project-Name   = "SME-Max-UAT"
    CLOPS_APPROVED = "True"
    Terraform      = "True"
  }
  vpc_id = aws_vpc.MAX-U3.id
}

resource "aws_security_group" "MAX-U3-MSK-SG" {
  description = "MAX-U3-MSK-SG"
  egress = [{
    cidr_blocks      = ["10.11.110.128/25", "10.250.4.16/28", "172.34.20.0/25"]
    description      = ""
    from_port        = 0
    ipv6_cidr_blocks = []
    prefix_list_ids  = []
    protocol         = "tcp"
    security_groups  = []
    self             = false
    to_port          = 65535
    },
    {
      cidr_blocks      = ["172.34.20.0/25", "10.250.4.16/28", "10.11.110.128/25"]
      description      = ""
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
  }]
  ingress = [{
    cidr_blocks      = ["10.11.106.0/25", "172.34.13.128/25", "10.250.196.192/26", "10.250.16.160/27", "10.250.25.96/27"]
    description      = "DEL-S2"
    from_port        = 9094
    ipv6_cidr_blocks = []
    prefix_list_ids  = []
    protocol         = "tcp"
    security_groups  = []
    self             = false
    to_port          = 9094
    },
    {
      cidr_blocks      = ["10.11.106.0/25", "172.34.13.128/25"]
      description      = "DEL-S2"
      from_port        = 2181
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 2181
    },
    {
      cidr_blocks      = ["10.11.106.0/25", "172.34.13.128/25"]
      description      = "DEL-S2"
      from_port        = 9092
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9092
    },
    {
      cidr_blocks      = ["10.250.70.0/24", "10.11.187.0/25"]
      description      = "DIGSYS-S3"
      from_port        = 2181
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 2181
    },
    {
      cidr_blocks      = ["10.250.70.0/24", "10.11.187.0/25"]
      description      = "DIGSYS-S3"
      from_port        = 9092
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9092
    },
    {
      cidr_blocks      = ["10.250.70.0/24"]
      description      = "DIGSYS-S3"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks      = ["110.11.187.0/25"]
      description      = "DIGSYSS3"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.251.12.0/22", "10.11.107.0/26"]
      description      = "MAX-U3"
      from_port        = 2181
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 2181
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.251.12.0/22", "10.11.107.0/26"]
      description      = "MAX-U3"
      from_port        = 9092
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9092
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.251.12.0/22", "10.11.107.0/26"]
      description      = "MAX-U3"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks      = ["10.11.187.0/25"]
      description      = "DIGSYS-S3"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks      = ["10.12.240.0/24"]
      description      = "SWITCHBOARD-QA"
      from_port        = 2181
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 2181
    },
    {
      cidr_blocks      = ["10.12.240.0/24"]
      description      = "SWITCHBOARD-QA"
      from_port        = 9092
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9092
    },
    {
      cidr_blocks      = ["10.12.240.0/24"]
      description      = "SWITCHBOARD-QA"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks      = ["10.11.115.128/25", "10.250.3.0/25", "10.250.16.128/27"]
      description      = "DEL-D"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
  ]
  name = "MAX-U3-MSK-SG"
  tags = {
    Name           = "MAX-U3-MSK-SG"
    Environment    = "UAT"
    CLOPS_FW       = "YES"
    Terraform      = "TRUE"
    Business-Unit  = "SME-MAX"
    Owner          = "chris.mollis.objectlab@sonymusic.com"
    Project-Code   = "SME-2000-0590E"
    Project-Name   = "SME-Max-UAT"
    CLOPS_APPROVED = "True"
    Terraform      = "True"
  }
  vpc_id = aws_vpc.MAX-U3.id
}

resource "aws_security_group" "MAX-U3-RDS-SG" {
  description = "MAX-U3-RDS-SG"
  egress = [{
    cidr_blocks      = ["0.0.0.0/0"]
    description      = "HTTP"
    from_port        = 80
    ipv6_cidr_blocks = []
    prefix_list_ids  = []
    protocol         = "tcp"
    security_groups  = []
    self             = false
    to_port          = 80
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "HTTPS"
      from_port        = 443
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 443
    },
    {
      cidr_blocks      = ["10.11.187.0/25"]
      description      = "DIGSYS-S3-IAPP"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.251.12.0/22", "10.11.107.0/26"]
      description      = "MAX-U3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.251.12.0/22", "10.11.107.0/26"]
      description      = "MAX-U3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },

  ]
  ingress = [{
    cidr_blocks      = ["10.250.92.0/24", "10.251.12.0/22", "10.11.107.0/26"]
    description      = "MAX-U3"
    from_port        = 3306
    ipv6_cidr_blocks = []
    prefix_list_ids  = []
    protocol         = "tcp"
    security_groups  = []
    self             = false
    to_port          = 3306
    },
    {
      cidr_blocks      = ["10.11.176.219/32"]
      description      = "FF-Bastion"
      from_port        = 3306
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 3306
    },
    {
      cidr_blocks      = ["10.11.176.200/32"]
      description      = "From cloudopsff-dbmonitor01"
      from_port        = 3306
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 3306
    },
    {
      cidr_blocks      = ["10.11.187.0/25"]
      description      = "DIGSYS-S3-IAPP"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks      = ["10.12.246.0/25"]
      description      = "VA-Shared"
      from_port        = 3306
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 3306
    },
    {
      cidr_blocks      = ["10.250.227.0/24"]
      description      = "CLSHRD-P-EKS"
      from_port        = 3306
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 3306
    },
    {
      cidr_blocks      = ["172.34.20.32/27"]
      description      = ""
      from_port        = 3306
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 3306
    },

  ]
  name = "MAX-U3-RDS-SG"
  tags = {
    Name           = "MAX-U3-RDS-SG"
    Environment    = "UAT"
    CLOPS_FW       = "YES"
    Terraform      = "TRUE"
    Business-Unit  = "SME-MAX"
    Owner          = "chris.mollis.objectlab@sonymusic.com"
    Project-Code   = "SME-2000-0590E"
    Project-Name   = "SME-Max-UAT"
    CLOPS_APPROVED = "True"
    Terraform      = "True"
  }
  vpc_id = aws_vpc.MAX-U3.id
}

resource "aws_security_group" "MAX-U3-ETL-SG" {
  description = "MAX-U3-ETL-SG"
  egress = [
    {
      cidr_blocks      = ["10.0.0.0/8"]
      description      = ""
      from_port        = 3306
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 3306
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "HTTP"
      from_port        = 80
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 80
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "HTTPS"
      from_port        = 443
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 443
    },
    {
      cidr_blocks      = ["10.12.246.64/26", "10.12.237.160/27"]
      description      = "SMTPS"
      from_port        = 587
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 587
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26"]
      description      = "MAX-U3-VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26"]
      description      = "MAX-U3-VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "NTP-TCP"
      from_port        = 123
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 123
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "NTP-UDP"
      from_port        = 123
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 123
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "SFTP-CLOUDOPS-8736"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
    {
      cidr_blocks      = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3-VPC-CIDR"
      from_port        = 2181
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 2181
    },
    {
      cidr_blocks      = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3-VPC-CIDR"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks      = ["10.250.70.0/24", "10.11.187.0/25"]
      description      = "DIGSYS-S3-VPC-CIDR"
      from_port        = 2181
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 2181
    },
    {
      cidr_blocks      = ["10.250.70.0/24", "10.11.187.0/25"]
      description      = "DIGSYS-S3-VPC-CIDR"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks      = ["172.34.20.0/25", "172.34.20.0/27", "172.34.20.32/27", "172.34.20.96/27", "10.250.242.128/26", "10.250.242.192/26", "10.250.242.96/27"]
      description      = "MAX-OH-S-VPC-CIDR"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks      = ["172.34.20.80/28", "172.34.20.0/27"]
      description      = "RDS"
      from_port        = 3306
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 3306
    },
  ]
  ingress = [
    {
      cidr_blocks      = ["10.11.176.219/32", "10.12.246.64/27", "10.250.2.64/27"]
      description      = "CloudOPS Bastions"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
    {
      cidr_blocks      = ["172.34.20.80/28", "172.34.20.0/27"]
      description      = "RDS"
      from_port        = 3306
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 3306
    },
    {
      cidr_blocks      = ["172.34.20.0/25", "172.34.20.0/27", "172.34.20.32/27", "172.34.20.96/27", "10.250.242.128/26", "10.250.242.192/26", "10.250.242.96/27"]
      description      = "MAX-OH-S-VPC-CIDR"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
  ]
  name   = "MAX-U3-ETL-SG"
  tags   = merge(var.tags, { Name = "MAX-U3-ETL-SG" })
  vpc_id = aws_vpc.MAX-U3.id
}

resource "aws_security_group" "MAX-U3-UTILS-SG" {
  description = "MAX-U3-UTILS-SG"
  egress = [
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "HTTP"
      from_port        = 80
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 80
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "HTTPS"
      from_port        = 443
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 443
    },
    {
      cidr_blocks      = ["10.12.246.64/26", "10.12.237.160/27"]
      description      = "SMTPS"
      from_port        = 587
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 587
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26"]
      description      = "MAX-U3-VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26"]
      description      = "MAX-U3-VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "NTP-TCP"
      from_port        = 123
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 123
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "NTP-UDP"
      from_port        = 123
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 123
    },
    {
      cidr_blocks      = ["162.49.199.159/32"]
      description      = "ftp.sonymusiccentral.com"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
  ]
  ingress = [
    {
      cidr_blocks      = ["10.11.176.219/32", "10.12.246.64/27", "10.250.2.64/27"]
      description      = "CloudOPS Bastions"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
  ]
  name   = "MAX-U3-UTILS-SG"
  tags   = merge(var.tags, { Name = "MAX-U3-UTILS-SG" })
  vpc_id = aws_vpc.MAX-U3.id
}

resource "aws_security_group" "MAX-U3-EKS-WORKER-SG" {
  description = "MAX-U3-EKS-WORKER-SG"
  egress = [
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "HTTP"
      from_port        = 80
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 80
    },
    {
      cidr_blocks      = ["172.34.20.0/25", "10.0.0.0/8"]
      description      = "MAX-OH-S"
      from_port        = 3306
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 3306
    },
    {
      cidr_blocks      = ["10.250.70.0/24", "10.11.187.0/25"]
      description      = "DIGSYS-Stage"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "HTTPS"
      from_port        = 443
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 443
    },
    {
      cidr_blocks      = ["10.12.246.64/26", "10.12.237.160/27"]
      description      = "SMTPS"
      from_port        = 587
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 587
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26", "10.251.12.0/22"]
      description      = "MAX-U3-VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26", "10.251.12.0/22"]
      description      = "MAX-U3-VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "NTP-TCP"
      from_port        = 123
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 123
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "NTP-UDP"
      from_port        = 123
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 123
    },
    {
      cidr_blocks = [
        "172.34.24.128/25",
        "172.34.32.64/28",
        "172.34.12.0/25",
        "172.34.12.192/28",
        "172.32.6.0/24",
      ]
      description      = ""
      from_port        = 3306
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 3306
    },
  ]
  ingress = [
    {
      cidr_blocks      = ["10.11.176.219/32", "10.12.246.64/27", "10.250.2.64/27"]
      description      = "CloudOPS Bastions"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26", "10.251.12.0/22"]
      description      = "MAX-U3-VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = [
        "10.12.237.0/24",
      ]
      description      = "TowerVPCcidr3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = [
        "10.12.246.0/25",
        "10.250.2.0/24",
      ]
      description      = "Shared-VPC"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26", "10.251.12.0/22"]
      description      = "MAX-U3-VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
  ]
  name   = "MAX-U3-EKS-WORKER-SG"
  tags   = merge(var.tags, { Name = "MAX-U3-EKS-WORKER-SG" })
  vpc_id = aws_vpc.MAX-U3.id
}

resource "aws_security_group" "MAX-U3-EKS-CLUSTER-SG" {
  description = "MAX-U3-EKS-CLUSTER-SG"
  egress = [
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "HTTP"
      from_port        = 80
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 80
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "HTTPS"
      from_port        = 443
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 443
    },
    {
      cidr_blocks      = ["10.12.246.64/26", "10.12.237.160/27"]
      description      = "SMTPS"
      from_port        = 587
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 587
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26", "10.251.12.0/22"]
      description      = "MAX-U3-VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26", "10.251.12.0/22"]
      description      = "MAX-U3-VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "NTP-TCP"
      from_port        = 123
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 123
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "NTP-UDP"
      from_port        = 123
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 123
    },
  ]
  ingress = [
    {
      cidr_blocks      = ["10.11.176.219/32", "10.12.246.64/27", "10.250.2.64/27"]
      description      = "CloudOPS Bastions"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
    {
      cidr_blocks      = ["10.0.0.0/8"]
      description      = "SME-VPN"
      from_port        = 443
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 443
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26", "10.251.12.0/22"]
      description      = "MAX-U3-VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = [
        "10.12.237.0/24",
      ]
      description      = "TowerVPCcidr3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = [
        "10.12.246.0/25",
        "10.250.2.0/24",
      ]
      description      = "Shared-VPC"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26", "10.251.12.0/22"]
      description      = "MAX-U3-VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
  ]
  name   = "MAX-U3-EKS-CLUSTER-SG"
  tags   = merge(var.tags, { Name = "MAX-U3-EKS-CLUSTER-SG" })
  vpc_id = aws_vpc.MAX-U3.id
}

resource "aws_security_group" "MAX-U3-API-GATEWAY-SG" {
  description = "Allow connection to Private API Gateways"
  egress = [{
    cidr_blocks      = ["0.0.0.0/0"]
    description      = "HTTP"
    from_port        = 80
    ipv6_cidr_blocks = []
    prefix_list_ids  = []
    protocol         = "tcp"
    security_groups  = []
    self             = false
    to_port          = 80
    }, {
    cidr_blocks      = ["0.0.0.0/0"]
    description      = "HTTPS"
    from_port        = 443
    ipv6_cidr_blocks = []
    prefix_list_ids  = []
    protocol         = "tcp"
    security_groups  = []
    self             = false
    to_port          = 443
    }, {
    cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26", "10.251.12.0/22", "10.249.4.208/28"]
    description      = "MAX-U3-VPC-CIDR"
    from_port        = 0
    ipv6_cidr_blocks = []
    prefix_list_ids  = []
    protocol         = "tcp"
    security_groups  = []
    self             = false
    to_port          = 65535
    },
    {
      cidr_blocks = [
        "10.0.0.0/8",
        "162.49.0.0/16",
        "192.168.0.0/16",
      ]
      description      = "VPN"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26", "10.251.12.0/22", "10.249.4.208/28"]
      description      = "MAX-U3-VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["172.34.20.80/28", "172.34.20.0/27"]
      description      = "MAX-OH-S-XAPP-1A & MAX-OH-S-XAPP-1B"
      from_port        = 3306
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 3306
    },
  ]
  ingress = [{
    cidr_blocks      = ["10.12.237.0/24"]
    description      = "TowerVPCcidr3"
    from_port        = 0
    ipv6_cidr_blocks = []
    prefix_list_ids  = []
    protocol         = "tcp"
    security_groups  = []
    self             = false
    to_port          = 65535
    }, {
    cidr_blocks      = ["10.250.2.0/24", "10.12.246.0/25"]
    description      = "Shared-VPC"
    from_port        = 0
    ipv6_cidr_blocks = []
    prefix_list_ids  = []
    protocol         = "tcp"
    security_groups  = []
    self             = false
    to_port          = 65535
    }, {
    cidr_blocks      = ["10.250.2.0/24", "10.12.246.0/25"]
    description      = "Shared-VPC"
    from_port        = 0
    ipv6_cidr_blocks = []
    prefix_list_ids  = []
    protocol         = "udp"
    security_groups  = []
    self             = false
    to_port          = 65535
    }, {
    cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26", "10.251.12.0/22", "10.249.4.208/28"]
    description      = "MAX-U3-VPC-CIDR"
    from_port        = 0
    ipv6_cidr_blocks = []
    prefix_list_ids  = []
    protocol         = "tcp"
    security_groups  = []
    self             = false
    to_port          = 65535
    }, {
    cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26", "10.251.12.0/22", "10.249.4.208/28"]
    description      = "MAX-U3-VPC-CIDR"
    from_port        = 0
    ipv6_cidr_blocks = []
    prefix_list_ids  = []
    protocol         = "udp"
    security_groups  = []
    self             = false
    to_port          = 65535
    },
    {
      cidr_blocks = [
        "10.0.0.0/8",
        "162.49.0.0/16",
        "192.168.0.0/16",
      ]
      description      = "VPN"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = [
        "10.0.0.0/8",
        "162.49.0.0/16",
        "192.168.0.0/16",
      ]
      description      = "VPN"
      from_port        = 80
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 80
    },
    {
      cidr_blocks      = []
      description      = "Inside SG"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = true
      to_port          = 65535
    },
    {
      cidr_blocks      = []
      description      = "Inside SG"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = true
      to_port          = 65535
    },
    {
      cidr_blocks      = ["10.12.240.0/24", "172.34.21.0/25", "10.249.2.192/28"]
      description      = "SWITCHBOARD-QA"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
  ]
  name   = "MAX-U3-API-GATEWAY-SG"
  tags   = merge(var.tags, { Name = "MAX-U3-API-GATEWAY-SG" })
  vpc_id = aws_vpc.MAX-U3.id
}

resource "aws_security_group" "MAX-U3-INT-ALB-SG" {
  description = "MAX-U3-INT-ALB-SG"
  egress = [
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "HTTP"
      from_port        = 80
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 80
    },
    {
      cidr_blocks      = ["172.34.20.0/25"]
      description      = "MAX-OH-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "HTTPS"
      from_port        = 443
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 443
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26", "10.251.12.0/22"]
      description      = "MAX-U3-VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["10.250.92.0/24", "10.11.107.0/26", "10.251.12.0/22"]
      description      = "MAX-U3-VPC-CIDR"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
  ]
  ingress = [
    {
      cidr_blocks      = ["10.0.0.0/8", "162.49.0.0/16", "192.168.0.0/16"]
      description      = "SME-VPN"
      from_port        = 443
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 443
    },
  ]
  name   = "MAX-U3-INT-ALB-SG"
  tags   = merge(var.tags, { Name = "MAX-U3-INT-ALB-SG" })
  vpc_id = aws_vpc.MAX-U3.id
}