Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
+1 vote
47 views
in Information Technology by (176k points)
Can I apply multiple security groups to an EC2 instance?

Please log in or register to answer this question.

1 Answer

+1 vote
by (176k points)

Yes, you can apply multiple security groups to an EC2 instance. Rules from all applied security groups are aggregated to determine the allowed traffic.

Example Code

Here’s an example of creating an AWS Security Group using AWS CLI:

# Create a new security group
aws ec2 create-security-group --group-name MySecurityGroup --description "My Security Group"

# Add an inbound rule to allow SSH access from a specific IP range
aws ec2 authorize-security-group-ingress --group-name MySecurityGroup --protocol tcp --port 22 --cidr 203.0.113.0/24 

This script first creates a new security group named "MySecurityGroup" with a description. Then, it adds an inbound rule to allow SSH (port 22) traffic from the IP range 203.0.113.0/24.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...