You create three security groups. Each one accepts traffic only from the previous layer:
| Security group | Inbound rule | Used by |
|---|---|---|
ALB-SG |
HTTP 80 from the internet (in part 6 you restrict it to CloudFront) | Application Load Balancer |
WebServer-SG |
HTTP 80 from ALB-SG |
WordPress EC2 instances |
Database-SG |
MySQL 3306 from WebServer-SG |
RDS database |
Open the Amazon EC2 console → Security Groups → Create security group.
Enter the following values:
ALB-SG, Description: Security group for the internet-facing Application Load Balancer.wordpress-vpc.HTTP, Source type Anywhere-IPv4, Description HTTP from the internet.
Keep the default outbound rule and choose Create security group.
Choose Create security group again, select VPC wordpress-vpc and enter:
WebServer-SG, Description: Security group for the private WordPress web servers.HTTP, Source – type ALB-SG and select the security group from the list, Description HTTP from the ALB only.
Choose Create security group.
Choose Create security group again, select VPC wordpress-vpc and enter:
Database-SG, Description: Security group for the RDS MySQL database.MYSQL/Aurora, Source – select WebServer-SG, Description MySQL from the web servers only.
Choose Create security group.
Neither WebServer-SG nor Database-SG has a rule for SSH (port 22). You connect to the instances with Session Manager instead.