Our Leadership team is attending CloudFest 2026, from Mar 22 - April 8. Schedule a Connect

Our Leadership team is attending CloudFest 2026, from Mar 22 - April 8.

Discuss MSP growth, DevOps excellence, and Cloud Transformation. Available for 1:1 meetings, Schedule a Connect

  • DevOps
    Case Study

    How we helped a development company rebuild DevOps for efficiency and scale.

    READ CASESTUDY
    icon

    24/7 DevOps as a Service

    Round-the-clock DevOps for uninterrupted efficiency.

    icon

    Infrastructure as a Code

    Crafting infrastructure with ingenious code.

    icon

    CI/CD Pipeline

    Automated CI/CD pipeline for seamless deployments.

    icon

    DevSecOps

    Integrated security in continuous DevOps practices.

    icon

    Hire DevOps Engineers

    Level up your team with DevOps visionaries.

    icon

    Consulting Services

    Navigate success with expert DevOps consulting.

  • TechOps
    Case Study

    How a US hosting leader scaled with us!

    READ CASESTUDY

    WEB HOSTING SUPPORT

    icon

    HelpDesk Support

    Highly skilled 24/7 HelpDesk Support

    icon

    Product Support

    Boost your product support with our expertise.

    MANAGED SERVICES

    icon

    Server Management

    Don’t let server issues slow you down. Let us manage them for you.

    icon

    Server Monitoring

    Safeguard your server health with our comprehensive monitoring solutions.

    STAFF AUGMENTATION

    icon

    Hire an Admin

    Transform your business operations with our expert administrative support.

    icon

    Hire a Team

    Augment your workforce with highly skilled professionals from our diverse talent pool.

  • CloudOps
    Case Study

    How we helped a Private Deemed University in India, save US $3500/m on hosting charges!

    READ CASESTUDY
    icon

    AWS Well Architected Review

    Round-the-clock for uninterrupted efficiency

    icon

    Optimize

    Efficient CloudOps mastery for seamless cloud management

    icon

    Manage

    Automated CI/CD pipeline for seamless deployments

    icon

    Migrate

    Upgrade the journey, Migrate & Modernize seamlessly

    icon

    Modernize

    Simplify compliance complexities with our dedicated services

    icon

    FinOps as a Service

    FinOps as a Service

  • SecOps
    Case Study

    Enabling financial grade platforms through strategic cloud modernisation.

    READ CASESTUDY
    icon

    VAPT

    Vulnerability Assessment and Penetration Testing

    icon

    Source Code Review

    Ensuring source code security ans safe practices to reduce risks

    icon

    Security Consultation

    On demand services for improving server security

    icon

    System Hardening

    Reduced vulnerability and proactive protection

    icon

    Managed SoC

    Monitors and maintains system security. Quick response on incidents.

    icon

    Compliance as a Service

    Regulatory compliance, reduced risk

  • Insights
    Case Study

    How we helped a Private Deemed University in India, save US $3,500/m on hosting charges!

    READ CASESTUDY
    icon

    Blog

    Explore our latest articles and insights

    icon

    Case Studies

    Read about our client success stories

    icon

    Flipbook

    Explore our latest Flipbook

    icon

    Events

    Join us at upcoming events and conferences

    icon

    Webinars

    Watch our educational webinar series

  • Our Story
  • Contact Us

Interested to collaborate?

Get in touch with us!

Ready to elevate your business with certified cloud expertise? Contact us today to learn how our team can help you leverage cloud technology to drive growth, streamline operations, and enhance security.

  • AWSAWS
  • Azure CloudAzure Cloud
  • Google CloudGoogle Cloud
  • Akamai CloudAkamai Cloud
  • OVHOVH
  • Digital OceanDigital Ocean
  • HetznerHetzner
  • Managed Services Overview
  • Kubernetes Consulting
  • DevOps as a Service
  • Infrastructure Monitoring
  • Kubernetes Consultancy Services
  • K8s & Cloud native Solutions
  • 24/7 Infrastructure Monitoring
  • DevOps as a Service
  • Cloud CI/CD Solutions
  • White Labeled MSP Support
  • Our story
  • Life@SupportSages
  • Insights
  • Careers
  • Events
  • Services
  • Managed Services

aws partneraws advanced partner
LinkedInFacebookXInstagramYouTube
SupportSages

Copyright © 2008 – 2026 SupportSages Pvt Ltd. All Rights Reserved.
Privacy PolicyLegal TermsData ProtectionCookie Policy
Identifying Security Groups Allowing All Traffic in a Specific Region-Python

Identifying Security Groups Allowing All Traffic in a Specific Region-Python

Author Profile
Arya P B
  • 3 min read
Identifying Security Groups Allowing All Traffic in a Specific Region-Python

Generating audio, please wait...

Introduction

Ensuring robust security is a paramount concern in cloud computing, and AWS offers powerful tools for managing and controlling access to resources. In this blog post, we will delve into a Python script designed to identify AWS security groups that permit all traffic within a specified region. By identifying and addressing such security configurations, you can bolster the overall security posture of your AWS infrastructure.

Prerequisites

Before delving into the script, make sure you have the following in place:

  • AWS account credentials configured on your machine.
  • Python installed (preferably version 3.x).
  • Boto3 library installed (install using pip install boto3).
Promotional banner

The Python Script

import json
import boto3
import sys

def inspect_security_groups(region):
# Initialize EC2 client with the specified region
client = boto3.client('ec2', region_name=region)

# Retrieve security group information
response = client.describe_security_groups()

# List to store results
results = []

# Iterate through security groups and their ingress rules
for security_group in response['SecurityGroups']:
for ingress_rule in security_group['IpPermissions']:
for ip_range in ingress_rule.get('IpRanges', []):
# Check if an ingress rule allows all traffic
if ip_range.get('CidrIp') == '0.0.0.0/0':
# Create a result object
result = {
'SecurityGroupId': security_group['GroupId'],
'SecurityGroupName': security_group['GroupName'],
'Type': ingress_rule['IpProtocol'],
'FromPort': ingress_rule.get('FromPort', 'N/A'),
'ToPort': ingress_rule.get('ToPort', 'N/A'),
'Description': security_group.get('Description', 'N/A')
}

# Append result to the list
results.append(result)
print(result)

# Check if the rule allows all ports (0-65535)
if ingress_rule.get('FromPort') == 0 and ingress_rule.get('ToPort') == 65535:
print(f"Open Port Detected in {security_group['GroupName']} ({security_group['GroupId']}): {ingress_rule['IpProtocol']} (All Ports)")

# Check if specific port ranges are open
elif 'FromPort' in ingress_rule and 'ToPort' in ingress_rule:
for port in range(ingress_rule['FromPort'], ingress_rule['ToPort'] + 1):
print(f"Open Port Detected in {security_group['GroupName']} ({security_group['GroupId']}): {ingress_rule['IpProtocol']}:{port}")

if __name__ == "__main__":
# Check if a region is provided as a command-line argument
if len(sys.argv) != 2:
print("Usage: python script_name.py <region>")
sys.exit(1)

# Get the region from the command-line argument
provided_region = sys.argv[1]

How to Use the Script

  1. Save the script as a Python file (e.g., security-grp-with-all-traffic-allowed.py).
  2. Open a terminal and navigate to the directory where the script is saved.
  3. Run the script by providing the AWS region as a command-line argument:
python3 security-grp-with-all-traffic-allowed.py.py <region>

Replace <region> with the desired AWS region (e.g., us-east-1).

1_3WbLsvK_udNaI9oCP0_XeQ.webp

1_xtFUIL_i81XCe9msvVGl9A.webp

Conclusion

This Python script streamlines the process of identifying AWS security groups that permit all traffic within a specific region. Regularly incorporating this script into your security practices ensures that your security groups align with the principle of least privilege, contributing to a secure AWS environment.

Improve your cloud security! This Python script identifies security groups in your AWS environment allowing unrestricted traffic. Regularly running this script helps you maintain the least privilege and bolster your cloud defenses. Take charge of your security

  • AWS
  • DevOps

Continue Your Journey With…

DevOps as a Service

DevOps as a Service

Let us do the heavy lifting for you

Promotional banner
Promotional banner

Analyzing AWS IAM Users: Access Key and Password Age

Analyzing AWS IAM Users: Access Key and Password Age
  • DevOps
logo

Analyzing AWS IAM Users: Access Key and Password Age

Analyzing AWS IAM Users: Access Key and Password Age
  • AWS
  • DevOps
logo

Auto-Restart EC2 Instances on Status Check Failure: Quick Setup Guide

Auto-Restart EC2 Instances on Status Check Failure: Quick Setup Guide
  • DevOps
logo

Auto-Restart EC2 Instances on Status Check Failure: Quick Setup Guide

Auto-Restart EC2 Instances on Status Check Failure: Quick Setup Guide
  • AWS
  • DevOps
logo

Posts by Arya P B

Athena