resource "aws_security_group" "elb_sg" { name = "elb_sg" vpc_id = aws_vpc.wp_vpc.id ingress { from_port = 80 to_port = 80 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } ingress { from_port = 443 to_port = 443 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } egress { from_port = 0 to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] } } resource "aws_security_group" "server_sg" { name = "server_sg" vpc_id = aws_vpc.wp_vpc.id ingress { from_port = 80 to_port = 80 protocol = "tcp" security_groups = [aws_security_group.elb_sg.id] } ingress { from_port = 443 to_port = 443 protocol = "tcp" security_groups = [aws_security_group.elb_sg.id] } egress { from_port = 0 to_port = 0 protocol = "-1" security_groups = [aws_security_group.elb_sg.id] } } resource "aws_security_group" "db_sg" { name = "db_sg" vpc_id = aws_vpc.wp_vpc.id ingress { from_port = 3306 to_port = 3306 protocol = "tcp" security_groups = [aws_security_group.server_sg.id] } }