A security group acts as a firewall for our EC2 instance. We can restrict access to our EC2 by defining on which protocol, port, and IP address EC2 is accessible. We can also define a CIDR block so that a group of IP addresses are able to access EC2 instances.
Go to AWS EC2 Management Console at https://console.aws.amazon.com/ec2/home.
Create a new security group under your AWS account:
Click Security Groups
under NETWORK & SECURITY
in the left menu. Click Create Security Group
:
Figure 3.3: Creating a security group
Provide a friendly security group name, description, and the VPC you want to create this security group. Also, we need to add a rule for inbound access. In our case, we will add a rule for SSH (port 22
), which will allow us to access an EC2 instance from any source (IP address). We can also provide an outbound rule, which will allow us to access specific destinations only. By default, the outbound rule is configured...