EC2 Security Groups

To create a security group with least privilege

Select a Region for the security group. Security groups are specific to a Region, so you should select the same Region in which you created your key pair. 

In the navigation pane, choose Security Groups

Choose Create security group

In the Basic details section, do the following: 

In the Inbound rules section, create the following rules (choose Add rule for each new rule): 

Warning

For security reasons, we don't recommend that you allow SSH access from all IPv4 addresses (0.0.0.0/0) to your instance, except for testing purposes and only for a short time. 

Choose Create security group


https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/get-set-up-for-amazon-ec2.html

Check