Security Group is a set of subnets running in Amazon Virtual Private Cloud (VPC) environment, allowing you to specify rules controlling inbound and outbound traffic.
Next, we will create 2 SGs representing public subnets (EC2 instance) and ALB (Application Load Balancer)
Access VPC Service. In the left navigation bar, select Security Group. Select create security group
| Security Group | Direction | Protocol | Port Range | Source/Destination | Description |
|---|---|---|---|---|---|
| alb-sg | Inbound | HTTP | 80 | 0.0.0.0/0 | Allow HTTP from internet |
| alb-sg | Inbound | HTTPS | 443 | 0.0.0.0/0 | Allow HTTPS from internet |
| alb-sg | Inbound | Custom TCP | 9000 | 0.0.0.0/0 | Allow traffic to Node.js app |
| alb-sg | Outbound | All | All | 0.0.0.0/0 | Allow all outbound traffic |
| public-ec2-sg | Inbound | HTTP | 80 | alb-sg | Allow HTTP from ALB |
| public-ec2-sg | Inbound | HTTPS | 443 | alb-sg | Allow HTTPS from ALB |
| public-ec2-sg | Inbound | Custom TCP | 9000 | alb-sg | Allow traffic from ALB to Node.js app |
| public-ec2-sg | Inbound | Custom TCP | 9000 | 0.0.0.0/0 | Allow direct access to Node.js app |
| public-ec2-sg | Inbound | SSH | 22 | All | Allow SSH access |
| public-ec2-sg | Outbound | All | All | 0.0.0.0/0 | Allow all outbound traffic |

