SG

resource "aws_security_group" "example_sg" {
  name        = "example-sg"
  description = "Security group di esempio"
  vpc_id      = aws_vpc.main.id

  ingress {
    description = "HTTP"
    from_port   = 80
    to_port     = 80
    protocol    = "tcp"
    cidr_blocks = ["144.44.2.33/32"]
  }

  ingress {
    description = "SSH"
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }

  egress {
    description = "All outbound"
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }

  tags = {
    Name = "example-sg"
  }
}

output "security_group_id" {
  description = "ID del Security Group creato"
  value       = aws_security_group.example_sg.id
}

output "security_group_rules" {
  description = "Ingress ed Egress del Security Group"
  value = {
    ingress = aws_security_group.example_sg.ingress
    egress  = aws_security_group.example_sg.egress
  }
}