A security group in AWS is a virtual firewall that controls the traffic allowed to and from the resources in a virtual priva...
A security group in AWS is a virtual firewall that controls the traffic allowed to and from the resources in a virtual private cloud (VPC) It acts as a filter for inbound and outbound traffic and determines what traffic is allowed to reach the resources associated with it. Security groups are stateful, which means that if a request is sent from an instance, the response traffic for that request is allowed to reach the instance regardless of the inbound security group rules. Responses to allowed inbound traffic are allowed to leave the instance, regardless of the outbound rules. Security groups do not filter traffic destined to and from Amazon Domain Name Services (DNS), Amazon Dynamic Host Configuration Protocol (DHCP), and Amazon EC2 instance metadata. Security groups can be created, viewed, updated, and deleted using the Amazon EC2 console and the command line tools. They can also be created using the AWS CLI. When a stack is launched, it is associated with one or more security groups, which determine what traffic is allowed to reach it. It's important to note that security is a shared responsibility between AWS and the user, and security groups are one of the tools for securing instances. It's recommended to configure them to meet the specific security needs.
HOW TO CREATE SECURITY GROUP: Here are the steps to create a security group in AWS: Open the Amazon VPC console or aws EC2 Dashboard navigate Network and Security click Security groups.
Click the Create security group option to configure the SG.
In the SG configuration, enter the name of the SG and the description of the security group.
Note that the name and description cannot be changed after the security group is created.
From VPC, choose the VPC for which to create the security group.
Add security group rules to allow inbound and outbound traffic. For example, you can allow traffic from specific IP addresses or ports. Click Create Security Group to create the SG.
Now we can attach this security group to the existing instance For that choose the instance and click Actions, choose Security, and click Change Security Groups.
In the Security group association step we need to search for already created SG
For example, we need to add an already created SG (techiev-sg), so we need to search and add the SG by clicking Add Security group.
If you want to delete existing the SG, you can remove it simply by clicking the Remove option and saving it. Now You have added the New security group and cleared the existing security group. For verification click the instance and check the security.