How to import two security groups in ingress rules using dynamic block

I created dynamic block for one of my security group which has two ingress rules with source set to two different security groups.
main.tf(without dynamicblock)

resource "aws_security_group" "secondary_sg_tcpci" {
  name        = "secondary_sg_tcpci"
  description = "RDS SG for TCPCI env"
  vpc_id      = data.aws_vpc.default.id
  ingress {
    from_port       = 22
    to_port         = 22
    protocol        = "tcp"
    security_groups = [local.server_jumpbox_security_groups]  ##Assocating to server_jumpbox_security_groups as source ###
  }
  ingress {
    from_port       = 22
    to_port         = 22
    protocol        = "tcp"
    security_groups = ["${aws_security_group.primary_sg.id}"]    ###Associating to primary_sg securitygroup######
    description     = "Secondary SG"
  }

  lifecycle {
    create_before_destroy = true
  }
}

locals {
  vpc_id                        = data.aws_vpc.default.id
  server_jumpbox_security_groups = data.aws_security_groups.server_sg.id
}

resource "aws_security_group" "primary_sg" {
  name        = "primary_security_group"
  description = "Allows outbound rules"
  vpc_id      = local.vpc_id
} 

resource "aws_security_group_rule" "rule_01" {
  type                     = "egress"
  from_port                = 22
  to_port                  = 22
  protocol                 = "tcp"
  source_security_group_id = aws_security_group.secondary_sg_tcpci.id       
  description              = "primary_sg rule01"
  security_group_id        = aws_security_group.primary_sg.id
}

I’ve added dynamic block for secondary_sg_tcpci

main.tf(with dynamicblock)

 resource "aws_security_group" "secondary_sg_tcpci" {
  for_each =  var.config
  name     = "${each.key}-rds"
  description = "RDS SG for TCPCI env"
  vpc_id      = data.aws_vpc.default.id
  dynamic "ingress" {
    for_each = var.ingress_rules 
    content {
      from_port       = ingress.value.port
      to_port         = ingress.value.port
      protocol        = ingress.value.protocol
      security_groups = [aws_security_group.primary_sg.id]
      
    }
  }
 }

variables.tf

variable "ingress_rules" {
  type = map(object({
    port            = number
    protocol        = string
   }))
  default = {
    "22" = {
      
      port            = 22
      protocol        = "tcp"  
    },
    "22" = {
      
      port       = 22
      protocol   = "tcp"
      
    }
  }
}

it’s fine till here. My old main.tf(without dynamicblock) secondary_sg_tcpci securitygroup has two different security groups as sources which are attached in ingress rules. One is primary_sg securitygroup and other is which I defined in locals server_jumpbox_security_groups. By just passing security_groups = [aws_security_group.primary_sg.id] this in my dynamicblock, it is only adding just one securitygroup as source in each rule.How to add the other securitygroup for other rules which is coming from locals as server_jumpbox_security_groups. I’m confused here how to acheive this. I tried defining like this security_groups = ingress.values.security_groups in my main.tf dynamicblock but was confused how to add list in variables.tf security_groups = [], Any suggestions is appreciated:)

main.tf

 resource "aws_security_group" "secondary_sg_tcpci" {
  for_each =  var.config
  name     = "${each.key}-rds"
  description = "RDS SG for TCPCI env"
  vpc_id      = data.aws_vpc.default.id
  dynamic "ingress" {
    for_each = var.ingress_rules 
    content {
      from_port       = ingress.value.port
      to_port         = ingress.value.port
      protocol        = ingress.value.protocol
      security_groups = ingress.values.security_groups
    }
  }
 }

variables.tf

variable "ingress_rules" {
  type = map(object({
    port            = number
    protocol        = string
    security_groups = list[string]
   }))
  default = {
    "22" = {

      port            = 22
      protocol        = "tcp" 
      security_groups = [] 
    },
    "22" = {

      port       = 22
      protocol   = "tcp"
      security_groups = [] 

    }
  }
}