πΒ What is a Security Group?
A Security Group (SG) acts as a virtual firewall that controls inbound and outbound traffic for your virtual machine (EC2 instance).
Works at instance level
Stateful (return traffic is automatically allowed)
Supports Allow rules only
π οΈ Steps to Create a Security Group in AWS
1οΈβ£ Sign in to AWS Console
Go to AWS Management Console
Navigate to: Services β EC2 β Security Groups
2οΈβ£ Click "Create Security Group"
Fill in the details:
Security group name β (e.g. datacenter-sg)
Description β Allow SSH and HTTP access
VPC β Select your VPC
π½ Configure Inbound Rules
Click Add Rule and configure:
Use My IP instead of Anywhere for SSH.
Avoid opening port 22 to the whole internet.
πΌ Configure Outbound Rules
Default rule allows All traffic
Usually no changes needed
3οΈβ£ Click Create Security Group
Your Security Group is now ready.
π Attach Security Group to EC2 Instance
1. Go to EC2 β Instances
1. Select your instance
1. Click Actions β Security β Change security groups
1. Select your new SG
1. Click Save
π― Result
SSH access controlled
Web traffic allowed
Instance protected by firewall rules
Secure and production-ready configuration
π Additional Guides
π Modify existing Security Group
π« Restrict SSH to corporate IP
ποΈ Production-level security group architecture
βοΈ Azure NSG version of this guide