# Security Group for EC2 module "security_group" { source = "terraform-aws-modules/security-group/aws" version = "6.0.0" name = "${var.project_name}-ec2-sg" description = "Security group for EC2 instance" vpc_id = module.vpc.vpc_id ingress_rules = { ssh = { from_port = 22 to_port = 22 ip_protocol = "tcp" description = "SSH from anywhere" cidr_ipv4 = "0.0.0.0/0" } http = { from_port = 80 to_port = 80 ip_protocol = "tcp" description = "HTTP from anywhere" cidr_ipv4 = "0.0.0.0/0" } https = { from_port = 443 to_port = 443 ip_protocol = "tcp" description = "HTTPS from anywhere" cidr_ipv4 = "0.0.0.0/0" } } egress_rules = { all = { from_port = -1 to_port = -1 ip_protocol = "-1" description = "Allow all outbound" cidr_ipv4 = "0.0.0.0/0" } } tags = { Name = "${var.project_name}-ec2-sg" } }