In this article we will be going to see how to change security group of an AWS EC2 instance. Many times ti happens that we keep security group common among many ec2 instances, even you keep ssh keys as same foe all, so that you need not to manage multiple things. But ideally it is not a good practice, consider for example you kept security group common for staging and prod. But you need to keep port 22 open for many developers working remotely. If the ssh keys are also same then they can access prod system as well. Therefore it is much better to keep security group as different for instances, even the staging and prod ssh keys should be different.
Please follow below approach to change the security group of an running aws ec2 instance.
Change Security group of AWS EC2 Instance:
STEP 1: Create Security Group
Goto Security group section option on EC2 instances dashboard and create a new security group that you want to apply to EC2 instance. Name it properly so you can recognize it later.
Choose instance whose security group you are looking to change, then from the actions dropdown, under the networking option you can see change security group. From here you can deselect the old security group and select the new security group that you want to apply to instance and save it. The new security group will be activated atr the same movement you change it.