This how-to guide will explain in detailed steps how you can attach or change security groups (sg) on an Amazon EC2 instance via the AWS Console or the AWS CLI.
How to attach a security group on an Amazon EC2 instance in the AWS Console
Visit the https://eu-central-1.console.aws.amazon.com/ec2/home?region=eu-central-1#Home: in the AWS Console and look for the EC2 instance you wish to attach a new security group.
To attach another security group to the EC2 instance, you need to click on the dropdown menu to select an available security group and then click Add security group.
Now in order to attach another security group to the instance, you run the following aws ec2 command in your terminal.