EC2 and EC2-VPC security groups

Hey, What should we essentially need to know while using EC2 and EC2-VPC security groups?

Hello Rishabh, a security group acts as a virtual firewall that controls the traffic for one or more instances. You can name the security groups like - sg-name , inorder to avoid any ambiguity.
AWS assigns each security group a unique ID in the form sg-xxx.
For custom security groups, you must provide it with a name and a description. Security group names and descriptions can be up to 255 characters in length. They are limited to the following characters:

EC2-Classic: ASCII characters

EC2-VPC: a-z, A-Z, 0-9, spaces, and ._-:/()#,@]+=&;{}!$*

Security groups behave differently for EC2 and EC2-VPC.
For EC2 security groups, you must use security groups created specifically for EC2 classic. When you launch an instance in EC2-Classic, you must specify a security group in the same region as the instance. You can not specify a security group that you created for a VPC when you launch an instance in EC2-Classic. After you launch an instance in EC2-Classic, you can not change its security groups. All that you can do is, you can add rules or remove rules from a security group, and those changes are automatically applied to all instances that are associated with the security group.
For EC2-VPC security groups, you must use security groups created specifically for your VPC. When you launch an instance in a VPC, you must specify a security group for that VPC. You can not specify a security group that you created for EC2-Classic when you launch an instance in a VPC.
Additionally, you can change its security groups. You can also change the rules of a security group, and those changes are automatically applied to all instances that are associated with the security group.
Also, when you associate multiple security groups to a single instance, the rules from each security group are effectively aggregated.
Hope this helps!