Create Security Group

VPC Security Group Concept

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.

Create VPC Security Group

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

Create Security Groups

Security GroupDirectionProtocolPort RangeSource/DestinationDescription
alb-sgInboundHTTP800.0.0.0/0Allow HTTP from internet
alb-sgInboundHTTPS4430.0.0.0/0Allow HTTPS from internet
alb-sgInboundCustom TCP90000.0.0.0/0Allow traffic to Node.js app
alb-sgOutboundAllAll0.0.0.0/0Allow all outbound traffic
public-ec2-sgInboundHTTP80alb-sgAllow HTTP from ALB
public-ec2-sgInboundHTTPS443alb-sgAllow HTTPS from ALB
public-ec2-sgInboundCustom TCP9000alb-sgAllow traffic from ALB to Node.js app
public-ec2-sgInboundCustom TCP90000.0.0.0/0Allow direct access to Node.js app
public-ec2-sgInboundSSH22AllAllow SSH access
public-ec2-sgOutboundAllAll0.0.0.0/0Allow all outbound traffic

2.1. Create Application Load Balancer SG

  • In Create Security Group interface, add Basic Details for alb-sg
  • Add corresponding Inbound Rules for alb-sg
  • Allows all outbound traffic
  • Select Create security group alb-sg.png

2.2 Create Public EC2 SG

  • In Create Security Group interface, add Basic Details for public-ec2-sg
  • Add corresponding Inbound Rules for public-ec2-sg:
    • HTTP (80) - Source: alb-sg
    • HTTPS (443) - Source: alb-sg
    • Custom TCP (9000) - Source: alb-sg
    • SSH (22) - Source: All IP
  • Allows all outbound traffic
  • Select Create security group public-ec2-sg.png

Complete!