Terraform dynamic block

Hello I am trying to create a module to create security groups with a dynamic block.
Terraform v1.6.2
on darwin_arm64

module/security-groups\main.tf
resource “aws_security_group” “security-groups” {
name = var.sg-name
description = “SG access”
vpc_id = var.vpc_id

dynamic “ingress” {
for_each = var.egress_rules
content {
from_port = ingress.value.from_port
to_port = ingress.value.to_port
protocol = ingress.value[“protocol”]
cidr_blocks = tolist(ingress.value[“cidr_blocks”])
security_groups = ingress.value[“security_groups”]
}
}
dynamic “egress” {
for_each = var.egress_rules
content {
from_port = egress.value[“from_port”]
to_port = egress.value[“to_port”]
protocol = egress.value[“protocol”]
cidr_blocks = tolist(egress.value[“cidr_blocks”])
security_groups = egress.value[“security_groups”]
}
}
tags = {
Name = var.sg-name
}
}

module/security-groups\output.tf
output “sg-id” {
value = aws_security_group.security_groups.id
}

module/security-groups\variable.tf
variable “vpc_id” {}
variable “sg-name” {}
variable “ingress_rules” {
type = list(object({
description = optional(string)
from_port = number
to_port = number
protocol = string
cidr_blocks = optional(list(string))
security_groups = optional(list(any))
}))
default =
}

variable “egress_rules” {
type = list(object({
from_port = number
to_port = number
protocol = string
cidr_blocks = optional(list(string))
security_groups = optional(list(any))
}))
default =
}

when I call the module in a main program main.tf
module “sps” {
source = “…/modules/security-groups”
vpc_id = module.vpc.vpc_id
sg-name = “db”
ingress_rules = [
{
description = “Allow HTTP”
from_port = 443
to_port = 443
protocol = “tcp”
cidr_blocks = [“0.0.0.0/0”]
#security_group_id = “”
},
]
egress_rules =
}

module “sps-ecs” {
source = “…/modules/security-groups”
vpc_id = module.vpc.vpc_id
sg-name = “dev”
ingress_rules = [
{
description = “Allow HTTP”
from_port = 80
to_port = 80
protocol = “tcp”
#I am trying to allow connection to the first sg got created above.
security_groups = module.security-group.sg-id
},
]
egress_rules =
}

security_groups does not work properly.
Error: Reference to undeclared module

│ on main.tf line 63, in module “sps-ecs”:
│ 63: security_groups = module.security-groups.sg-id

│ No module call named “security-groups” is declared in the root module.

someone can let me know my error, thanks for the help

all working now. not need help thanks