resource "aws_default_security_group" "DIGSYS-S3-DEFAULT-SG" {
  vpc_id = aws_vpc.DIGSYS-S3.id
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-DEFAULT-SG" 
    Name = "DIGSYS-S3-DEFAULT-SG"
    })
}

resource "aws_security_group" "DIGSYS-S3-GSIRT-SG" {
  name        = "DIGSYS-S3-GSIRT-SG"
  description = "DIGSYS-S3-GSIRT-SG"
  egress = [
    {
      cidr_blocks      = ["10.250.70.0/24", "10.11.187.0/25", "10.249.1.48/28"]
      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.70.0/24", "10.11.187.0/25", "10.249.1.48/28"]
      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.70.0/24", "10.11.187.0/25", "10.249.1.48/28"]
      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.70.0/24", "10.11.187.0/25", "10.249.1.48/28"]
      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 = "DIGSYS-S3-GSIRT-SG" 
    CLOPS_FW = "NO"
  })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-OCM-SG" {
  description = "DIGSYS-S3-OCM-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "10.0.0.0/8",
      ]
      description      = "RDS"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = [
        "10.0.0.0/8",
      ]
      description      = "RDS"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = [
        "10.11.187.0/25",
      ]
      description      = "RDS"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      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"
      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"
      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", "10.250.70.150/32"]
      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-UAT"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = ["10.11.176.219/32", "10.12.246.64/27", "10.250.2.64/27", "10.250.70.150/32"]
      description      = "CloudOPS Bastions"
      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", "10.12.246.64/27", "10.250.2.64/27", "10.250.70.150/32"]
      description      = "CloudOPS Bastions"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks = ["10.11.176.219/32", "10.12.246.64/27", "10.250.2.64/27", "10.250.70.150/32"]
      description      = "CloudOPS Bastions"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = ["10.11.187.0/25", "10.250.70.0/24"]
      description      = "DIGSYS-S3 VPC CIDRs"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = [
        "10.11.110.128/25",
      ]
      description      = "DIGSYS-S RDS Subnets"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = [
        "10.11.110.128/25",
      ]
      description      = "digsyss-ocm01/2"
      from_port        = 1521
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1521
    },
    {
      cidr_blocks = [
        "10.11.120.0/26",
      ]
      description      = "smeed2-scan.server.arvato-systems.de"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = [
        "10.11.121.149/32",
      ]
      description      = "exunxlvz05850.server.arvato-systems.de"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = [
        "10.11.49.64/28",
      ]
      description      = "degtluv0323/4.server.arvato-systems.de"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = [
        "10.11.96.128/26",
      ]
      description      = "gtunxlvz06526, gtunxlvs07013, gtunxlvv07016 & gtunxlvw07017.server.arvato-systems.de"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = [
        "10.11.97.229/32",
      ]
      description      = "gtunxlvv06679.server.arvato-systems.de"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = [
        "162.49.124.129/32",
      ]
      description      = "SCA-Culpeper-NAT"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = [
        "162.49.150.31/32",
      ]
      description      = "HKGSMEDB0001.me.sonymusic.com"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = [
        "162.49.169.132/32",
      ]
      description      = "degtlun5843.server.arvato-systems.de"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = [
        "162.49.169.228/32",
      ]
      description      = "degtlun5844.server.arvato-systems.de"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = ["10.12.214.128/25","10.250.25.0/26","10.249.3.32/28"]
      description      = "GRPSNV-D3"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
{
      cidr_blocks = ["10.11.113.0/26","10.11.119.0/25","10.250.6.0/24","10.11.177.64/26","10.250.47.32/27","10.249.4.192/28"]
      description      = "GRPS-D2"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },

  ]
  name   = "DIGSYS-S3-OCM-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-OCM-SG"
    CLOPS_FW = "NO"
     })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-DSMSAPP01A-SG" {
  description = "DIGSYS-S3-DSMSAPP01A-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "192.168.248.0/21",
      ]
      description      = "Atlas Mongo DB"
      from_port        = 27015
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 27017
    },

    {
      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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      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"
      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"
      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.11.176.219/32", "10.12.246.64/27", "10.250.2.64/27"]
      description      = "CloudOPS Bastions"
      from_port        = 9090
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9090
    },
    {
      cidr_blocks      = ["10.250.70.150/32"]
      description      = "digsyss3-tools01"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
    {
      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
    },
  ]
  name = "DIGSYS-S3-DSMSAPP01A-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-DSMSAPP01A-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-EOM2APP01-SG" {
  description = "DIGSYS-S3-EOM2APP01-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      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"
      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"
      from_port        = 123
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 123
    },
    {
      cidr_blocks      = ["10.250.70.0/26", "10.11.187.0/25", "10.11.187.64/26"]
      description      = "DIGSYS-S3-XDMZ-IAPP-CIDR"
      from_port        = 7090
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 7090
    },
  ]
  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.70.150/32"]
      description      = "digsyss3-tools01"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
    {
      cidr_blocks      = ["10.250.70.0/26", "10.11.187.0/25", "10.11.187.64/26"]
      description      = "DIGSYS-S3-XDMZ-IAPP-CIDR"
      from_port        = 7090
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 7090
    },
  ]
  name = "DIGSYS-S3-EOM2APP01-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-EOM2APP01-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-CSA2APP01-SG" {
  description = "DIGSYS-S3-CSA2APP01-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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["162.49.251.209/32"]
      description      = "gtunxlva06527.server.arvato-systems.de"
      from_port        = 17800
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 17800
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "NTP"
      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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
	  {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "NTP"
      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.250.70.0/26", "10.11.187.0/25"]
      description      = "DIGSYS-S3-XDMZ-IAPP-CIDR"
      from_port        = 443
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 443
    },
    {
      cidr_blocks      = ["10.250.70.0/26", "10.11.187.0/25"]
      description      = "DIGSYS-S3-XDMZ-IAPP-CIDR"
      from_port        = 80
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 80
    },
    {
      cidr_blocks      = ["10.250.70.0/26", "10.11.187.0/25"]
      description      = "DIGSYS-S3-XDMZ-IAPP-CIDR"
      from_port        = 8080
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 8080
    },
    {
      cidr_blocks      = ["10.0.0.0/8"]
      description      = "VPN IP"
      from_port        = 8080
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 8080
    },
    {
      cidr_blocks      = ["10.250.70.150/32"]
      description      = "digsyss3-tools01"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
  ]
  name = "DIGSYS-S3-CSA2APP01-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-CSA2APP01-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-APIGW-NLB-SG" {
  description = "DIGSYS-S3-APIGW-NLB-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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
  ]
  ingress = [
    {
      cidr_blocks = [
        "10.11.0.0/16",
        "10.12.0.0/16",
        "162.49.0.0/16",
        "192.168.10.0/23",
        "192.168.12.0/24",
        "192.168.155.0/24",
        "192.168.227.0/24",
      ]
      description      = "SME-INTRANET"
      from_port        = 443
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 443
    },
  ]
  name     = "DIGSYS-S3-APIGW-NLB-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-APIGW-NLB-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-DRD2APP01-SG" {
  description = "DIGSYS-S3-DRD2APP01-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
  ]
  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 = "DIGSYS-S3-DRD2APP01-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-DRD2APP01-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-LAMBDA-SG" {
  description = "DIGSYS-S3-LAMBDA-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = [
        "192.168.248.0/21",
      ]
      description      = "Atlas Mongo DB"
      from_port        = 27015
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 27017
    },
  ]
  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", "162.49.0.0/16", "192.168.0.0/16"]
      description      = "VPN IPs"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
  ]
  name     = "DIGSYS-S3-LAMBDA-SG"
  tags     = merge(var.tags, { 
    Name = "DIGSYS-S3-LAMBDA-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-RDS-SG" {
  description = "DIGSYS-S3-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 = ["10.0.0.0/8"]
      description      = "RDS Stored Proc"
      from_port        = 8080
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 8080
    },
    {
      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.121.91/32"]
      description      = "sftp-int-smart-stg-oci.smedigitalapps.com"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
    {
      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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      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"]
      description      = "SME-VPN"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      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      = "Open for SEND-GRID"
      from_port        = 587
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 587
    },
    {
      cidr_blocks = ["172.34.20.0/25", "10.250.4.16/28", "10.11.113.240/28", "10.11.108.32/28"]
      description      = "MAX-OH-S"
      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.113.240/28", "10.11.108.32/28"]
      description      = "MAX-OH-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.120.228/32"]
      description      = "exunxlvx05016.server.arvato-systems.de"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = ["10.11.49.66/32"]
      description      = "degtluv0319.server.arvato-systems.de"
      from_port        = 8080
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 8080
    },
    {
      cidr_blocks = ["10.250.1.0/25", "10.11.107.0/25", "10.250.203.64/26"]
      description      = "EOM-FF-P"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.1.0/25", "10.11.107.0/25", "10.250.203.64/26"]
      description      = "EOM-FF-P"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
  ]
  ingress = [
    {
      cidr_blocks = ["10.11.104.128/25", "10.11.109.64/26", "10.250.6.0/24", "10.249.5.96/28", "10.11.187.32/32", "10.250.242.181/32"]
      description      = "AOMA-S"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks = ["10.11.104.128/25", "10.11.109.64/26"]
      description      = "AOMA-S"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = ["10.11.107.128/25", "172.34.29.0/25"]
      description      = "EOM-FF-P"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = ["10.11.109.48/28", "10.11.109.16/28"]
      description      = "ARFF-P-DB-Subnet"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "172.34.20.0/25"]
      description      = "MAX-OH-S"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = ["10.11.112.176/28", "10.11.112.160/28"]
      description      = "ARFF-D-DB-Subnet"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = ["172.34.14.192/27"]
      description      = "MAX-D"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = ["10.0.0.0/8"]
      description      = "VPN"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = ["10.0.0.0/8"]
      description      = "VPN"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks = ["172.34.20.0/25"]
      description      = "MAX-OHS"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks = ["10.0.0.0/8"]
      description      = "SME-VPN"
      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        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks      = ["10.11.176.219/32", "10.12.246.64/27", "10.11.176.205/32"]
      description      = "BASTIONS"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks = ["10.11.96.134/32","10.11.96.133/32","10.11.96.165/32","10.11.96.166/32","10.11.113.39/32"]
      description      = "Arvatok8s"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks = ["10.11.113.0/26","10.11.119.0/25","10.11.177.64/26","10.250.47.32/27","10.249.4.192/28"]
      description      = "GRPS-D2"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks = ["10.12.214.128/25","10.250.25.0/26","10.249.3.32/28"]
      description      = "GRPSNV-D3"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks = ["10.11.113.128/26","10.11.178.160/27","10.249.7.144/28","10.250.26.192/26","10.11.119.128/26"]
      description      = "GRPS-P2"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
       {
      cidr_blocks = ["10.12.215.128/25","10.250.97.0/24"]
      description      = "GRPS-P1"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks = ["10.11.113.32/28"]
      description      = "GRPS-D2-APP-1A"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks = ["10.12.214.192/27"]
      description      = "GRPSNV-D3-IDMZ-1A"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks = ["10.250.242.192/26"]
      description      = "DIGSYS-D3-XAPP-1B"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks      = ["10.11.114.0/27","10.11.114.32/27"]
      description      = "AOMA-D3 mi-load-comparison-test lambda"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks      = ["10.11.176.64/26"]
      description      = "EOM-DEV-CCSHARE-FF-IDMZ-1B"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    }
  ]
  name = "DIGSYS-S3-RDS-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-RDS-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-EAI2APP01-SG" {
  description = "DIGSYS-S3-EAI2APP01-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.20.0/25"]
      description      = "MAX-OH-S-MSK"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks = ["10.11.187.103/32"]
      description      = "rds"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
  ]
  ingress = [
    {
      cidr_blocks = ["10.12.246.64/27", "10.250.2.64/27", "10.250.70.150/32", "10.12.246.75/32", "10.11.176.219/32", "10.250.11.140/32"]
      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", "162.49.0.0/16", "192.168.0.0/16", "172.34.20.96/27"]
      description      = "SME Intranet"
      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      = "SME Intranet"
      from_port        = 80
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 80
    },
    {
      cidr_blocks = ["172.34.21.0/25"]
      description      = "Switchboard_DEV"
      from_port        = 443
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 443
    },
    {
      cidr_blocks = ["10.11.187.103/32"]
      description      = "rds"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks = [
        "10.11.188.0/24",
        "10.250.6.0/24"
      ]
      description      = "digsysd3-eks"
      from_port        = 80
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 80
    },
    {
      cidr_blocks = [
        "10.251.11.0/24",
        "10.251.13.0/24"
      ]
      description      = "digsysp3-eks"
      from_port        = 80
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 80
    },
    {
      cidr_blocks = [
        "10.12.246.0/25",
        "10.250.227.0/24"
      ]
      description      = "github-runner"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
  ]
  name = "DIGSYS-S3-EAI2APP01-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-EAI2APP01-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-MSK-SG" {
  description = "DIGSYS-S3-MSK-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.12.252.0/24"]
      description      = "SWB-P"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.12.252.0/24"]
      description      = "SWB-P"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks      = ["10.250.242.0/24", "10.11.188.0/25","10.11.119.108/32", "10.11.119.111/32", "10.11.119.85/32", "10.11.119.94/32"]
      description      = "DIGSYS-D3"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks = ["10.12.240.16/28", "10.12.240.96/28"]
      description      = "qa"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks      = ["0.0.0.0/0"]
      description      = "TEST"
      from_port        = 27017
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 27017
    },
  ]
  ingress = [
    {
      cidr_blocks = ["10.250.242.202/32"]
      description      = "digsysd3-akhq01"
      from_port        = 2181
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 2181
    },
    {
      cidr_blocks = ["10.250.242.202/32"]
      description      = "digsysd3-akhq01"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks      = ["10.250.242.0/24", "10.11.188.0/25","10.11.119.108/32", "10.11.119.111/32", "10.11.119.85/32", "10.11.119.94/32"]
      description      = "DIGSYS-D3"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks = ["10.0.0.0/8"]
      description      = "VPC-CIDR"
      from_port        = 9098
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9098
    },
    {
      cidr_blocks = ["10.11.112.128/26"]
      description      = "CARMA-D"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks = ["10.11.113.44/32"]
      description      = "grpsd2-application02"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks = ["10.11.115.0/25", "10.250.6.0/24"]
      description      = "CARMA-T"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks = ["10.11.119.16/28", "10.11.119.0/28"]
      description      = "GRPS-D2"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks = ["10.11.119.192/26", "10.250.24.0/27", "10.11.177.0/26", "10.11.178.128/28"]
      description      = "CARMA-S"
      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", "172.34.21.0/25"]
      description      = "SWB-QA"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks = ["10.12.246.0/24"]
      description      = "Prometheus"
      from_port        = 11001
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 11001
    },
    {
      cidr_blocks = ["10.12.246.0/24"]
      description      = "Prometheus"
      from_port        = 11002
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 11002
    },
    {
      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.12.240.16/28", "10.12.240.96/28"]
      description      = "qa"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks = ["10.12.214.224/27", "10.12.214.192/27"]
      description      = "sme-label-copy-schedule-dev-use1-cluster-01 worker nodes"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
  ]
  name = "DIGSYS-S3-MSK-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-MSK-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-DRA2APP01-SG" {
  description = "DIGSYS-S3-DRA2APP01-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      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      = "smtp.sendgrid.net"
      from_port        = 587
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 587
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "NTP"
      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"
      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",
	"162.49.0.0/16",
	"192.168.0.0/16",
      ]
      description      = "Sony-vpn"
      from_port        = 9990
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9990
    },
    {
      cidr_blocks      = ["10.250.70.150/32"]
      description      = "digsyss3-tools01"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
    {
      cidr_blocks      = ["10.250.70.0/26", "10.11.187.0/25", "10.11.176.219/32"]
      description      = "DIGSYS-S3-XDMZ-IAPP-CIDR"
      from_port        = 8080
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 8080
    },
  ]
  name = "DIGSYS-S3-DRA2APP01-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-DRA2APP01-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-EOM1APP01-SG" {
  description = "DIGSYS-S3-EOM1APP01-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["162.49.251.209/32"]
      description      = "tsmegrps.arvato-systems.de"
      from_port        = 17800
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 17800
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "NTP"
      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"
      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      = "NTP"
      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"
      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.250.70.150/32"]
      description      = "digsyss3-tools01"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
    {
      cidr_blocks      = ["10.250.70.0/26", "10.11.187.0/25"]
      description      = "DIGSYS-S3-XDMZ-IAPP-CIDR"
      from_port        = 8080
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 8080
    },
  ]
  name = "DIGSYS-S3-EOM1APP01-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-EOM1APP01-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-TOOLS-SG" {
  description = "DIGSYS-S3-TOOLS-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.104.128/25", "10.11.109.64/26"]
      description      = "AOMA-S"
      from_port        = 9094
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 9094
    },
    {
      cidr_blocks = ["0.0.0.0/0"]
      description      = "Github"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "NTP"
      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"
      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", "10.250.70.150/32"]
      description      = "CloudOPS Bastions"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
  ]
  name = "DIGSYS-S3-TOOLS-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-TOOLS-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-DS2APP01-SG" {
  description = "DIGSYS-S3-DS2APP01-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      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"
      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"
      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.250.70.150/32"]
      description      = "digsyss3-tools01"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
    {
      cidr_blocks      = ["10.250.70.0/26", "10.11.187.0/25"]
      description      = "DIGSYS-S3-XDMZ-IAPP-CIDR"
      from_port        = 8080
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 8080
    },
  ]
  name = "DIGSYS-S3-DS2APP01-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-DS2APP01-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-O3APP-SG" {
  description = "DIGSYS-S3-O3APP-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["162.49.192.141/32"]
      description      = "gtlsmeads0101.me.sonymusic.com"
      from_port        = 636
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 636
    },
    {
      cidr_blocks = ["162.49.192.144/32"]
      description      = "gtlsmeads0102.me.sonymusic.com"
      from_port        = 636
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 636
    },
  ]
  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 = "DIGSYS-S3-O3APP-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-O3APP-SG"
    CLOPS_FW = "NO"
     })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-UTIL01-SG" {
  description = "DIGSYS-S3-UTIL01-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "10.0.0.0/8",
      ]
      description      = "RDS"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 1480
    },
    {
      cidr_blocks = [
        "10.11.187.0/25",
      ]
      description      = "RDS"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["35.156.89.2/32", "52.29.94.181/32"]
      description      = "digsysdevsftp.medigitalapps.com"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
    {
      cidr_blocks = ["10.250.242.64/28", "10.250.242.80/28"]
      description      = "pg-baseline-5"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "NTP"
      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"
      from_port        = 123
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 123
    },
    {
      cidr_blocks = ["162.49.251.209/32"]
      description      = "tsmegrps.arvato-systems.de / gtunxlva06527.server.arvato-systems.de"
      from_port        = 17800
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 17800
    },
   {
      cidr_blocks = [
        "10.11.121.91/32",
      ]
      description      = "sftp-int-smart-stg-oci.smedigitalapps.com"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65534
    },
    {
      cidr_blocks = [
        "10.11.121.91/32",
      ]
      description      = "sftp-int-smart-stg-oci.smedigitalapps.com"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65534
    },
  ]
  ingress = [
    {
      cidr_blocks = ["10.11.176.219/32", "10.12.246.64/27", "10.250.2.64/27", "10.250.70.150/32"]
      description      = "CloudOPS Bastions"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
  ]
  name = "DIGSYS-S3-UTIL01-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-UTIL01-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-INT-LB-SG" {
  description = "DIGSYS-S3-INT-LB-SG"
  egress = [
    {
      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.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.0.0.0/8"]
      description      = "VPN IP"
      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      = "NTP"
      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"
      from_port        = 123
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 123
    },
    {
      cidr_blocks = [
        "10.250.70.211/32",
      ]
      description      = "digsyss3-eom2-nlb"
      from_port        = 7090
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 7090
    },
    {
      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
    },
  ]
  ingress = [
    {
      cidr_blocks = [
        "10.0.0.0/8",
        "162.49.0.0/16",
        "192.168.0.0/16",
      ]
      description      = "SME-INTRANET"
      from_port        = 443
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 443
    },
    {
      cidr_blocks = ["172.34.20.0/24"]
      description      = "MAX"
      from_port        = 443
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 443
    },
    {
      cidr_blocks = [
        "10.250.70.211/32",
      ]
      description      = "digsyss3-eom2-nlb"
      from_port        = 7090
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 7090
    },
    {
      cidr_blocks = [
        "10.250.242.128/26",
        "10.250.242.192/26"
      ]
      description      = "digsysd3-eks"
      from_port        = 80
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 80
    },
    {
      cidr_blocks = [
        "10.251.11.192/26",
        "10.251.11.128/26"
      ]
      description      = "digsys-p3-eks"
      from_port        = 80
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 80
    }
  ]
  name = "DIGSYS-S3-INT-LB-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-INT-LB-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-EXT-LB-SG" {
  #checkov:skip=CKV_AWS_260: Ensure no security groups allow ingress from 0.0.0.0:0 to port 80
  description = "DIGSYS-S3-EXT-LB-SG"
  egress = [
    {
      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
    },
  ]
  ingress = [
    {
      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
    },
  ]
  name = "DIGSYS-S3-EXT-LB-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-EXT-LB-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-TESTERS01-SG" {
  description = "DIGSYS-S3-TESTERS01-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      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"
      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"
      from_port        = 123
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 123
    },
    {
      cidr_blocks      = ["10.251.11.0/24", "10.11.189.0/25", "10.249.6.208/28", "10.251.12.0/22", "10.11.187.176/28", "10.251.26.0/23"]
      description      = "DIGSYS-P3 VPC-CIDR"
      from_port        = 1480
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
  ]
  ingress = [
    {
      cidr_blocks = ["10.11.176.219/32", "10.12.246.64/27", "10.250.2.64/27", "10.250.70.150/32"]
      description      = "CloudOPS Bastions"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
  ]
  name   = "DIGSYS-S3-TESTERS01-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-TESTERS01-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-MIDICT-SG" {
  description = "DIGSYS-S3-MIDICT-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      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.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      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"
      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"
      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", "10.250.70.150/32"]
      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.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.0.0.0/8"]
      description      = "RDS Stored Proc"
      from_port        = 8080
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 8080
    },
    {
      cidr_blocks = ["10.11.187.0/25"]
      description      = "DIGSYS-S3 APP Subnets"
      from_port        = 8080
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 8080
    },
  ]
  name   = "DIGSYS-S3-MIDICT-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-MIDICT-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-LTI-SG" {
  description = "DIGSYS-S3-LTI-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      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.70.0/24", "10.11.187.0/25", "10.11.189.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", "10.11.189.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.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.11.110.128/25", "172.34.16.128/25", "10.250.19.192/26"]
      description      = "EOM-FF-S"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["10.250.242.0/24", "10.11.188.0/25"]
      description      = "DIGSYS-D3"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      from_port        = 0
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 65535
    },
    {
      cidr_blocks = ["172.34.25.0/24"]
      description      = "DIGSYS-FF-AUDIT"
      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"
      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"
      from_port        = 123
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 123
    },
    {
      cidr_blocks = [
        "172.34.25.224/28",
        "172.34.25.240/28",
      ]
      description      = "DIGSYS-FF-AUDIT-RDS-1A & DIGSYS-FF-AUDIT-RDS-1B"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
    {
      cidr_blocks = ["10.251.11.0/24", "10.11.189.0/25", "10.251.12.0/22", "10.11.187.176/28", "10.251.26.0/23"]
      description      = "DIGSYS-P3"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
  ]
  ingress = [
    {
      cidr_blocks = ["10.11.176.219/32", "10.12.246.64/27", "10.250.2.64/27", "10.250.70.150/32"]
      description      = "CloudOPS Bastions"
      from_port        = 22
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 22
    },
  ]
  name   = "DIGSYS-S3-LTI-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-LTI-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-PGBOUNCER-SG" {
  description = "DIGSYS-S3-PGBOUNCER-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      = "DNS-TCP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      cidr_blocks = [
        "0.0.0.0/0",
      ]
      description      = "DNS-UDP"
      from_port        = 53
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "udp"
      security_groups  = []
      self             = false
      to_port          = 53
    },
    {
      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.70.0/24", "10.11.187.0/25", "10.11.189.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", "10.11.189.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 = [
        "0.0.0.0/0",
      ]
      description      = "NTP"
      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"
      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", "10.250.70.150/32"]
      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 Intranet"
      from_port        = 5432
      ipv6_cidr_blocks = []
      prefix_list_ids  = []
      protocol         = "tcp"
      security_groups  = []
      self             = false
      to_port          = 5432
    },
  ]
  name   = "DIGSYS-S3-PGBOUNCER-SG"
  tags   = merge(var.tags, { 
    Name = "DIGSYS-S3-PGBOUNCER-SG" 
    CLOPS_FW = "NO"
    })
  vpc_id = aws_vpc.DIGSYS-S3.id
}

resource "aws_security_group" "DIGSYS-S3-DSMS-SCIM-SG" {
  name   = "DIGSYS-S3-DSMS-SCIM-SG"
  description = "DIGSYS-S3-DSMS-SCIM-SG"
  vpc_id = aws_vpc.DIGSYS-S3.id

  ingress {
    from_port       = 8103
    to_port         = 8103
    protocol        = "tcp"
    security_groups = [aws_security_group.DIGSYS-S3-DSMSAPP01A-SG.id, aws_security_group.DIGSYS-S3-DSMS-ADMIN-SG.id, aws_security_group.DIGSYS-S3-DSMS-GATEWAY-SG.id, aws_security_group.DIGSYS-S3-INT-LB-SG.id]
    description     = "Allow DSMS App and Internal LB to communicate on port 8103"
  }

  egress {
    from_port   = 0
    to_port     = 65535
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "aws_security_group" "DIGSYS-S3-DSMS-ADMIN-SG" {
  name   = "DIGSYS-S3-DSMS-ADMIN-SG"
  description = "DIGSYS-S3-DSMS-ADMIN-SG"
  vpc_id = aws_vpc.DIGSYS-S3.id

  ingress {
    from_port       = 9090
    to_port         = 9090
    protocol        = "tcp"
    security_groups = [aws_security_group.DIGSYS-S3-DSMSAPP01A-SG.id, aws_security_group.DIGSYS-S3-INT-LB-SG.id]
    description     = "Allow DSMS App and Internal LB to communicate on port 9090"
  }

  egress {
    from_port   = 0
    to_port     = 65535
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}


resource "aws_security_group" "DIGSYS-S3-DSMS-AUTH-SG" {
  name   = "DIGSYS-S3-DSMS-AUTH-SG"
  description = "DIGSYS-S3-DSMS-AUTH-SG"
  vpc_id = aws_vpc.DIGSYS-S3.id

  ingress {
    from_port       = 9100
    to_port         = 9100
    protocol        = "tcp"
    security_groups = [aws_security_group.DIGSYS-S3-DSMSAPP01A-SG.id, aws_security_group.DIGSYS-S3-DSMS-ADMIN-SG.id, aws_security_group.DIGSYS-S3-DSMS-GATEWAY-SG.id]
    description     = "Allow DSMS App and Internal LB to communicate on port 9100"
  }

  egress {
    from_port   = 0
    to_port     = 65535
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "aws_security_group" "DIGSYS-S3-DSMS-RS-CLEARANCES-SG" {
  name   = "DIGSYS-S3-DSMS-RS-CLEARANCES-SG"
  description = "DIGSYS-S3-DSMS-RS-CLEARANCES-SG"
  vpc_id = aws_vpc.DIGSYS-S3.id

  ingress {
    from_port       = 8102
    to_port         = 8102
    protocol        = "tcp"
    security_groups = [aws_security_group.DIGSYS-S3-DSMSAPP01A-SG.id, aws_security_group.DIGSYS-S3-INT-LB-SG.id, aws_security_group.DIGSYS-S3-DSMS-ADMIN-SG.id, aws_security_group.DIGSYS-S3-DSMS-GATEWAY-SG.id]
    description     = "Allow DSMS App and Internal LB to communicate on port 8102"
  }

  egress {
    from_port   = 0
    to_port     = 65535
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}


resource "aws_security_group" "DIGSYS-S3-DSMS-NOTES-SG" {
  name   = "DIGSYS-S3-DSMS-NOTES-SG"
  description = "DIGSYS-S3-DSMS-NOTES-SG"
  vpc_id = aws_vpc.DIGSYS-S3.id
  ingress {
    from_port       = 8750
    to_port         = 8750
    protocol        = "tcp"
    security_groups = [aws_security_group.DIGSYS-S3-DSMSAPP01A-SG.id, aws_security_group.DIGSYS-S3-INT-LB-SG.id, aws_security_group.DIGSYS-S3-DSMS-ADMIN-SG.id, aws_security_group.DIGSYS-S3-DSMS-GATEWAY-SG.id]
    description     = "Allow DSMS App and Internal LB to communicate on port 8750"
  }

  egress {
    from_port   = 0
    to_port     = 65535
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "aws_security_group" "DIGSYS-S3-DSMS-MI-SG" {
  name   = "DIGSYS-S3-DSMS-MI-SG"
  description = "DIGSYS-S3-DSMS-MI-SG"
  vpc_id = aws_vpc.DIGSYS-S3.id
  ingress {
    from_port       = 8550
    to_port         = 8550
    protocol        = "tcp"
    security_groups = [aws_security_group.DIGSYS-S3-DSMSAPP01A-SG.id, aws_security_group.DIGSYS-S3-DSMS-ADMIN-SG.id, aws_security_group.DIGSYS-S3-DSMS-GATEWAY-SG.id, aws_security_group.DIGSYS-S3-DSMS-CONTRACTS-SG.id, aws_security_group.DIGSYS-S3-DSMS-RS-CLEARANCES-SG.id, aws_security_group.DIGSYS-S3-DSMS-NOTES-SG.id, aws_security_group.DIGSYS-S3-DSMS-CLEARANCES-SG.id]
    description     = "Allow DSMS App and Internal LB to communicate on port 8550"
  }

  egress {
    from_port   = 0
    to_port     = 65535
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}
resource "aws_security_group" "DIGSYS-S3-DSMS-CLEARANCES-SG" {
  name   = "DIGSYS-S3-DSMS-CLEARANCES-SG"
  description = "DIGSYS-S3-DSMS-CLEARANCES-SG"
  vpc_id = aws_vpc.DIGSYS-S3.id
  ingress {
    from_port       = 8100
    to_port         = 8100
    protocol        = "tcp"
    security_groups = [aws_security_group.DIGSYS-S3-DSMSAPP01A-SG.id, aws_security_group.DIGSYS-S3-INT-LB-SG.id, aws_security_group.DIGSYS-S3-DSMS-ADMIN-SG.id, aws_security_group.DIGSYS-S3-DSMS-GATEWAY-SG.id]
    description     = "Allow DSMS App and Internal LB to communicate on port 8100"
  }

  egress {
    from_port   = 0
    to_port     = 65535
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "aws_security_group" "DIGSYS-S3-DSMS-CONTRACTS-SG" {
  name   = "DIGSYS-S3-DSMS-CONTRACTS-SG"
  description = "DIGSYS-S3-DSMS-CONTRACTS-SG"
  vpc_id = aws_vpc.DIGSYS-S3.id
  ingress {
    from_port       = 8000
    to_port         = 8000
    protocol        = "tcp"
    security_groups = [aws_security_group.DIGSYS-S3-DSMSAPP01A-SG.id, aws_security_group.DIGSYS-S3-INT-LB-SG.id, aws_security_group.DIGSYS-S3-DSMS-ADMIN-SG.id, aws_security_group.DIGSYS-S3-DSMS-GATEWAY-SG.id]
    description     = "Allow DSMS App and Internal LB to communicate on port 8000"
  }

  egress {
    from_port   = 0
    to_port     = 65535
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "aws_security_group" "DIGSYS-S3-DSMS-USER-SG" {
  name   = "DIGSYS-S3-DSMS-USER-SG"
  description = "DIGSYS-S3-DSMS-USER-SG"
  vpc_id = aws_vpc.DIGSYS-S3.id
  ingress {
    from_port       = 8104
    to_port         = 8104
    protocol        = "tcp"
    security_groups = [aws_security_group.DIGSYS-S3-DSMSAPP01A-SG.id, aws_security_group.DIGSYS-S3-DSMS-ADMIN-SG.id,  aws_security_group.DIGSYS-S3-DSMS-GATEWAY-SG.id]
    description     = "Allow DSMS App and Internal LB to communicate on port 8104"
  }

  egress {
    from_port   = 0
    to_port     = 65535
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "aws_security_group" "DIGSYS-S3-DSMS-GATEWAY-SG" {
  name   = "DIGSYS-S3-DSMS-GATEWAY-SG"
  description = "DIGSYS-S3-DSMS-GATEWAY-SG"
  vpc_id = aws_vpc.DIGSYS-S3.id
  ingress {
    from_port       = 8762
    to_port         = 8762
    protocol        = "tcp"
    security_groups = [aws_security_group.DIGSYS-S3-DSMSAPP01A-SG.id, aws_security_group.DIGSYS-S3-INT-LB-SG.id, aws_security_group.DIGSYS-S3-DSMS-ADMIN-SG.id]
    description     = "Allow DSMS App and Internal LB to communicate on port 8762"
  }

  egress {
    from_port   = 0
    to_port     = 65535
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "aws_security_group" "DIGSYS-S3-DSMS-EUREKA-SG" {
  name   = "DIGSYS-S3-DSMS-EUREKA-SG"
  description = "DIGSYS-S3-DSMS-EUREKA-SG"
  vpc_id = aws_vpc.DIGSYS-S3.id
  ingress {
    from_port       = 8761
    to_port         = 8761
    protocol        = "tcp"
    security_groups = [aws_security_group.DIGSYS-S3-DSMSAPP01A-SG.id, aws_security_group.DIGSYS-S3-INT-LB-SG.id, aws_security_group.DIGSYS-S3-DSMS-ADMIN-SG.id]
    description     = "Allow DSMS App and Internal LB to communicate on port 8761"
  }

  egress {
    from_port   = 0
    to_port     = 65535
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}
