Creating AWS Security Group for a range of ports in Terraform
If you look at AWS docs https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/security-group-rules.html they support port range. The way to do it with terraform is:
from_port = 4011 and to_port = 4999
See also the terraform docs:
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group#from_port

I want to create the following AWS security group in Terraform, using Hashi Corp Language. In this configuration the second ingress rule contains the range of ports, but such a syntax is not supported by Terraform.
In current implementation Terraform treats port's range as the math expression and computes the difference which gives the negative value. If I close the port range in parenthesis it fails because it requires number format.
What is the appropriate way to create ingress rule for a large range of ports?
  resource "aws_security_group" "sg_nx" {
  name   = "sg_nx"
  vpc_id = aws_vpc.vpc.id
  ingress {
    from_port   = 4000
    to_port     = 4000
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
  ingress {
    from_port   = 4011-4999
    to_port     = 4011-4999
    protocol    = "udp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

Using list does not work either. I know Terraform allows dynamicly generated resources, how to implement it in this case?
