How to work around security group/rules limits?

Hello Friends

We are planning to migrate some of our workloads to AWS EC2. One Service Running depends on a Server and we want to restrict access to this server granulary through Security Groups.

Now we noted, that AWS seems to have a limit of 60 Rules per Security Group and 6 attached Security Groups per Network Interface. While this can be extended through a quota request, the product of attached Security Groups multiplied by the max rules must not exceed 1000.

While i understand that more than 1000 granular connections can be an architectural nightmare, this is not completely impossible in our setup and is considered as a risk.

Do you also expierience similar problems? How do you handle such cases?

Thx in advance & Best wishes


Related discussions:

Startup company brand new to AWS - does this sound sensible?
A few beginner questions
Learning AWS CLI: How can I get a list of instance ID's?
How long to setup AWS users?
How do you address SSH keypair management for EC2?
Create / Renew Let's Encrypt certificates using temp EC2 machines
Email notifications
Why doesn't EC2 offer 'console' access? (Not a complaint, just genuinely curious)
13 Practical and Tactical Cloud Security Controls in EC2 (x/posted from /r/geek)
My EC2 free tier expired and now I am being charged $1900. What should I do?
EC2 High Memory Cluster Eight Extra Large Instance - 244 GiB RAM
EC2 outage in one of the US-East availability zones?
What type of EC2 instances to use for EMR?
EC2 Issue with instances losing network connectivity
AWS CLI Tool vs EC2 CLI?
Looking for a good book on AWS/EC2 that covers Cloud Formation. Any recommendations? Thanks.
EC2 Container Service In Action
Easiest way to upload images
Auto Recovery for Amazon EC2
Help! I may have accidentally deleted my Amazon Hosted Site
EC2 Dumb Question: rebooting from AWS Console vs. the instance
Is there a way to configure an EC2 instance such that it is not accessible to the outside world, with the exception of computers of a few privileged users (e.g. admins, developers, etc.)?
Amazon Launches New File Storage Service For EC2
Windows NAT Service
Do I need SSL encryption between the ELB and my EC2 instance?
new EC2 Run Command
Lost ssh access to ec2 instance
EC2 Run Command: poweroff
EBS Automated backups?
Slow Excel performance in EC2 with Storage Gateway
Gaming on EC2 g2.2xlarge, need some help.
`aws s3 sync` performance?
Question about deploying to EC2 Service
EC2 Windows server RAID configurations
Strange sleep/hibernation mode for Windows Server on EC2?
Traffic recording and analyzing?
What is the "Service" url of CloudWatch, for including in the trust relationship?
Cloudformation do work before EC2 stack destroy
AMI not a clone of the instance it was built from?
EC2 User Data script - add to Source Control, so server to download and run on launch
cryptography in EC2 instances
Did I miss an announcement about security group descriptions? Awesome feature!
getting instance ids via aws cli
Looking for a way to limit the incoming bandwidth of an EC2 instance. Any recommendations?
ELI5: What is this new network-load-balancer's benefit ?
We host 200+ sites (subdomains of other sites only), over an ELB, attached to 4 EC2 instances. Best way to implement SSL over all sites?
AD / DS and multiple regions, how to connect?
Understanding Burst Instances
Introducing Amazon EC2 P3 Instances
X1e Instances in Five More Sizes and a Stronger SLA
Stupid question about EC2/command line and Python
My visual notes on recent changes to the EC2 host, from Peter Desantis' AWS reInvent 2017 keynote
Download EC2 image?
Create an AMI from an EC2 with no down time
Amazon AutoScale help with Scale In
Is there anyway to encrypt data moving from EFS to EC2?
EC2 Instance Update - Faster Processors (Z1d) and More Memory (R5)
How do I manage passwords on AWS EC2?
EC2 instance self terminates? When attempting to resize
How can I get student promotional codes?
Windows EC2 help.
Upgrading from EC2 t2.micro
Looking for a script to remove a security group from all EC2 instances.
AWS Ops Automator: EC2 Copy Snapshot
TIL of the TerminateInstanceInAutoScalingGroup API
Application not connecting from Workspace to EC2 SQL
Microsoft SQL BYOL Program Ending
IPv6 range to EC2
Is this best approach to setting up alarm if EC2 is not available?
No instance types found matching your filter criteria
Reserved Instance Question: T2 and T3
Best way to isolate EC2 instance after possible breach for further investigation?
How much is t3.2xlarge ECU @ 100% cpu utilization?
There's Elastic IP, is there a domain name equivalent?
EC2 Spot viable as a dirt-cheap backup BI workstation?
How does the Amazon Web Services (AWS) Charges/Bills?
New AWS Pricing Calculator for EC2 and EBS
Amazon EC2 now offers On-Demand Capacity Reservations
Sysprep Failing on Windows 2016 EC2
AWS Cognito <> EC2 Postgres Synchronize?
Recommendations for keeping a public DNS secure in AWS.
Sharepoint.com blocking AWS resources
Notification Regarding Cross-stack Requests from AWS
How to lower my ec2 instance costs?
RDP pass-through from Windows jump box to EC2
Best practice for getting older Postgres DB onto RDS without downtime?
How to configure EC2 Fleet ASG to launch On-demand instances when there are not enough available Spot instances?
Create EBS Volume from tarball
Any advise on this?
Only one "developer" account allowed -- is it possible for devs to upload their public SSH keys to AWS?
AWS WAN Speed Improvements for NFS/CIFS
Sidechannel md_clear cpu flags not being passed to EC2 instances?
What's the fastest S3 upload speed anyone has witnessed for a single file?
Sharing AMI's and ensuring standard is maintained with AMI's
Load balancer + hundreds of SSL's
Open source AWS services visualization and configuration tool
Feature by Region Chart
Hundreds of exposed Amazon cloud backups found online – TechCrunch
CLI tool for Data Scientists to manage ML instances
Using new vCPU-based On-Demand Instance limits with Amazon EC2
Do I need to install SSL certificate in Tomcat since AWS has a free Certificate Manager Etc ?
New Instance Sizes Again - Gap Fillers
GitHub - 0x4447/0x4447_product_maintenance: 🧢 A stack which will deploy a EC2 instance with auto shutdown
Availability Zone Question
EC2 Reserved instance expired
Alfred workflow to Open AWS in your browser via aws-vault
Did I misconfigure something? Minecraft server on EC2.
Who can access an AWS Account when using AD/AzureAD as an identity provider
With cloud providers lobbying so hard for defense contracts, is there a possibility of AWS/GCP/Azure providing the Gov with backdoor access to customer data?
Best way to audit/review network security (Network ACLs, Security Groups)?
I'm confused about Amazon EKS nodeGroups vs managedNodeGroups
Suggestion: AWS console browser notification
Is it best practice to have two separate ALBs: one for your web tier and the other for your application tier?
Is there any use-case for multiple IPs to single instance?
Private subnet communication
boto3 users, I've built a (hopefully) better reference site for us
AWS Security groups ingress cidr blocks, are these public or private IPs?
EC2 Price Reduction – For EC2 Instance Saving Plans and Standard Reserved Instances
Tell us more about your AWS Step Functions business use cases.
What is the best practice to send sensitive data from AWS to a mobile application ?
Securing EC2 instances that host HTTP/S & SFTP services
KMS best practices - allocation of CMKs
TLS 1.2 to become the minimum for all AWS FIPS endpoints | Amazon Web Services
AWS Customers are Opting in to Sharing AI Data Sets with Amazon Outside their Chosen Regions and Many Didn’t Know
c5ad instances inbound!
Is it possible to record the speaker output of an EC2 instance?
Issue with storage gateways?
Api Gateway now supports mTLS
EC2 autoscaling instance lifecycle and user data execution
How much traffic can an EC2 Ubuntu 20.04 with 512mb of ram reasonably handle? My personal site is acting a little strange
Cool new community developed tool - ec2-spot-converter - convert existing EC2 instances back and forth from on-demand and 'persistent' Spot billing models while preserving instance and network attributes, storage, and more.
Adding temporary users to EC2 instance
aws-gate 0.10.0 released with support for connecting to SSM managed nodes, better error reporting and minor performance improvements. If you are using SSM to access your instances, you want to check it out!
I'm an AWS newbie. If I totally hose an EC2 instance, can I just restore a snapshot and be like nothing happened?
Best way to mount an NFS (with rc.local being deprecated)?
EBS Root device Snapshots - is instance shutdown really required?
Better alternatives to EC2?
Witness someone brute forcing my EC2 instance. I have 0 users so I'm not concerned, however how can I learn from this? Or better how do I prevent a brute force attempt?
Which EC2 instance type has the best single core performance?
EC2 X2gd Instances – Graviton2 Power for Memory-Intensive Workloads
Troubleshoot Boot and Networking Issues with New EC2 Serial Console
Someone accidentally provisioned a gigantic ec2 instance, bill is very high
Windows EC2 instances seeing all drives as removable
How do Lambda functions get security credentials?
Exporting an ec2 to VMware
New – Amazon EC2 M6i Instances Powered by the Latest-Generation Intel Xeon Scalable Processors | Amazon Web Services
Changing EC2 Windows AMI screen resolution
AWS FSx Lustre File Permissions
Worst vulnerabilities in the AWS stack?
AWS introduces changes to access denied errors for easier permissions troubleshooting
S3 Large File
AWS EC2 North Virginia outage resolves but some issues linger
Am I not charged for using EC2 Free Tier after 12 months?
Do you find EC2 ImageBuilder to be ridiculously slow?
Only Using AWS for EC2 - Did I forgot something to secure my Account?
Rant: AWS keeps on rejecting my EC2 resource limit increase request
Hosting 1000 WordPress Websites
Using AWS security services to protect against, detect, and respond to the Log4j vulnerability
Terminated EC2 instance still being billed.
Performance overhead by using SSL for EC2 and RDS(MySQL) communication
Stop Putting AWS Credentials in GitHub Secrets
Creating image from ec2
There was a problem connecting to your instance
Part of AWS console is unresponsive?
[Networking] Bridged connection between two EC2 instances
What Inbound Rule (what IPs) do I need to get "Instance Connect" to work without allowing SSH traffic inbound from any/all addresses (0.0.0.0)? Ubuntu Svr 20.04
EC2 instance RDP Session only showing command prompt
Introducing Amazon EC2 I4i instances
Windows Server EC2 Pricing
Using CloudTrail to Pivot to AWS Accounts
How to deploy a web app on multi EC2 servers?
What AWS service am I looking for?
What is a common use case for EC2 Image builder?
Migrate to VPC from EC2 confusion
Create Launch Template CLI w/ File option?
Do EC2 instances have usernames and passwords on top of keys?
How to give someone access to your vm
Personal project suggestions to keep AWS architecting skills sharp?
57 API Access Keys found on PyPi. Great Whitehat Effort and Tooling.
Malware Analysis on an EC2
AWS free tier EC2 can easily handle 20000+ WebSocket connections with real-time feature flag evaluations.
Registration open for AWS re:Inforce 2023 | Amazon Web Services
EC2 fax service suggestions
Would running a websocket server on Fargate become absurdly expensive?
Best SSO for AWS??
Amazon Verified Permissions is now generally available
Best way to store secret seed values
CF stuck at CREATE_IN_PROGRESS on EC2 at IamInstanceProfile
AWS Notification Email: Update to AWS & GitHub OIDC (No Customer Action)
Anyone know of a equivalent to Cloud SQL Auth proxy on GCP but for AWS?
EC2-Classic Networking has been deprecated
Can't connect with SSH to EC2 instance after reboot
Is there a good way to “shrink” EBS volume?
Database engine in RDS vs EC2-hosted
Amazon EC2 Instance Metadata Service IMDSv2 by default
AWS Security Incident Response Playbook
Can restarting EC2 instance serving a web app cause weird duplicated actions?
Need to setup Wordpress website with AWS including EC2 & Cloudfront services. How?
What are AWS certifications good for?
AWS Guard Duty Finding
n00bish question, can a fleet of EC2 instances serve baseline API calls but use lambdas for overflow/spikes in traffic? (economy)
EBS vs. Instance store for root and data volumes
Spinning up 10,000 EC2 VMS for a minute
New U7i High Memory Instances with 12 TiB to 32 TiB of Memory
How much would a dev/test environment like this cost each month?
Aws breach in account with MFA
Most Expensive Architecture Challenge
Microsoft technical support on AWS EC2 instances
ec2instances.info requests for feedback
amplify vs ec2 for nextjs 15 on aws
Will We Ever Have A Solver Service?
Load testing setup with k6 + Grafana, full guide for Devs, QAs & DevOps
ec2instances.info newsletter for new instance types/changes + other updates
Creating a Site to Site VPN between EC2 and VGW without using a marketplace AMI
I hate the current EC2 instance type explorer page
New Release: EC2 Capacity Manager
Performance evaluation of the new c8a instance family
Why are EC2 Mac instances so expensive & who are they actually for?
I bypassed AWS API Gateway auth with a trailing slash. Got $12K bounty.
Best EC2 instance size for a self-hosted Supabase production backend — t4g.large or 4 vCPU/16 GB?
AWS Support Problems
Amazon Web Services (AWS) Tutorial 7 - What is EC2? How to Create an EC...
Creating NACLs
Passed CSAA Today
Extend an Existing on on-prem AD to EC2
Passed SAA-C02!
A question for working AWS cloud engineers
Passed AWS CCP, when should I start for SAA?
Sanity check before I give up on my AWS dream, or is there anything else I can/should do after getting certs?
Aws projects
Question about a question I got in DB Specialty Exacm..
What’s the correct answer for this ?
Cloud Practitioner passed with 820
Can someone help me understand the answer to this question about ASGs and adding new volume?
Should i abandon the SysOps Exam and do the SAA Exam instead? (3rd Attempt)
AWS SysOps Exam Hand-on labs: Permission denied
What is the correct answer to this? I say its A but a lot of places has it as "B"
Doubt about a question
Instances
Solutions Architect: Confused about this TDojo question
Mistakes happen and Accidental stops or termination of an EC2 instance isn't far. Make use of AWS’s Stop Protection and Termination Protection features to prevent unwanted shutdowns and deletions. Easily enabled via the Console or CLI—quick to set up and saves you from downtime and data loss!
Inconsistent amount of EC2 instances created
How pedantic is the Security Specialty exam?
AWS EC2 Instances - Stop/Start and AMI Management (xpost from /r/sysadmin)
New 'Feature' - Everyone has my document
How does AWS Kinesis helps with scaling when I have to still create EC2 consumers with auto-scaling?
EC2 micro just stops randomly for ~5minutes

I dont have a perfect answer to that however I wonder if those security groups rules can be re grouped? Maybe use an AI to help grouoing those?

I also wonder how come so many granular rules?

How granular are you going?

You can use a security group within a security group, so traffic from one sg to another is allowed then out those instances in that sg

Avoid solving this by simply increasing the security group limits. If you have that many granular rules, consider using prefix lists to group CIDR ranges, separate security groups by service or access pattern, or move some filtering to AWS Network Firewall. It’s worth reviewing whether every connection really needs an individual rule. That might simplify the architecture considerably

You’re likely doing something wrong. Can you explain the nature of the kind of security group rules you’d like in an ideal world? When I see people ask this, the solution they’re looking for is actually to use “source security group ID” as the client identifier, rather than IP address ranges. But it’s hard to say without knowing what you’re actually trying to do.

I am not familiar with your system, but you can try AWS Network Firewall, they have 30,000 rules limit, and even this can be increased.

Two details that change the maths before you go near the quota:

  1. A rule that references another security group counts as one rule no matter how many instances carry that group. If most of your sources are EC2 instances or other AWS resources, give each client tier its own SG and reference it as the source. Thousands of hosts can then collapse into a handful of rules.

  2. Managed prefix lists help with organisation, but not with the limit. A referenced prefix list counts against the quota by its max-entries value, not as one rule, so a 200-entry list still uses 200.

NACLs aren’t the escape hatch either. They’re stateless, ordered and capped much lower (20 rules by default), so they’re only useful for coarse subnet-level denies.

If your sources really are 1000+ distinct external IPs (partners, branch offices, on-prem ranges), I’d stop treating IP allowlisting as the authorisation layer. Put the server behind something that authenticates the caller: an ALB with mutual TLS (or mTLS terminated at the service itself), Verified Access for user-facing traffic, or PrivateLink for partners who are also on AWS. The SG then only needs to allow the load balancer or endpoint. Network Firewall makes sense if you need central L3/L4 policy at that scale, but it’s a cost and ops jump for a single service.

How many distinct sources are you really expecting, and are they mostly inside AWS or outside it? That decides which of these fits.

I did want to note that managed prefix lists don’t necessarily solve this.

If you are creating 10 rules and use a managed prefix list that has a max of 10 entries, that counts as 100 rules. Even if there are only 2 entries in the prefix list.

Remember that you can use Security Group as a source/destination for the rules. So if you have 15 servers that each need access via 10 rules on another server, create a SG for the source and destination (2x SG total). Create 10 rules in each (ingress in one and egress in the other) referencing the other SG as the source/destination.

Now every server that needs that access gets the source SG and the target resource gets the target SG.

We’ve found this works well if you generally have one service/use per server or use cases that overlap access needs. But you may still hit the SG per resource limit.

Restricting AD inbound has been the hard one for us. It’s like 14 rules with a huge amount of sources.

Exactly, it makes it worse in some cases because it reserves X number of “slots” in the SG for whatever the size of the list is and unless you have each PL sized perfectly, it’s going to waste space in the SG.

Without knowing more about the context, environment, etc this is the first thing that comes to mind.

One angle I haven’t seen mentioned yet: stop making that one server the enforcement point.

Put a Network Load Balancer (or ALB if the traffic is HTTP) in front of the service and move the per-source allow-listing up a tier. The per-partner rules then live on the load balancer’s security group or on AWS Network Firewall in front of it, and the server’s own security group allows traffic only from the load balancer — one rule instead of a thousand. That also buys you a stable place to add or remove a partner without touching the server at all, and without waiting on a rule change to propagate across a thousand-entry group.

A second thing worth checking before you chase the quota: how many of those sources are actually distinct networks? Partners that all come in through one NAT gateway, one on-prem egress, or one branch office can usually be collapsed into a single supernet, and that’s often where the count drops from scary to manageable. Same for anything inside AWS — if the sources are other services in your accounts, one security group per role referenced as the source collapses hundreds of instance IPs into a single rule, and it stays correct when instances are replaced.

If after that you still genuinely need hundreds of distinct external sources, that’s the point where I’d reach for Network Firewall with stateful rule groups rather than keep stretching security groups — but only after the collapsing exercise, because a firewall full of rules you didn’t need is its own maintenance headache.

The 1,000 is per network interface, so the biggest win is using source security groups instead of individual IPs, since one rule covers every instance in that group. Prefix lists won’t save you rule count either, because AWS counts their max entries against the quota, so use them for tidiness and not capacity. If you still need more granular than that, I’d do the fine-grained part at a proxy, Network Firewall, or the app itself and keep the security group as the coarse outer layer.

referencing source security groups only works if the clients are actually inside the same vpc or peered though, if OP is whitelisting external customer IPs theyre stuck with raw CIDR blocks

Insufficient information provided, where do these clients connect ftom, etc.

Think of security groups as a primitive firewall restriction. Each network interface has one security group on it, the group defines which ports and protocols are open, and what other systems in AWS can access these resources.

There are situations where you need something more complicated than the above, but don’t start with that until you understand why you need that. In the majority of cases you don’t need the complex multi security group setup.

A security group is not by instance (you can, but don’t), but type of instance. So if for example you have 10 web servers to distribute the load across then they all have the same security group.

Keep it simple where you can.

You may be tempted to have a security group that grants web server access, another group for SSH, etc and compose the access permissions to an instance from these multiple security groups, don’t, that way lies madness especially when you start restricting things with source security group IDs.

> we want to restrict access to this server granulary through Security Groups
You’re doing it wrong

Can also work across cloudwan in the same region I think?

Thx! Its also exactly restricting AD inbound what we are struggling with. How did you handle this?

Thx! We basically want to restrict inbound access to the domain controller we are putting in AWS.

How do we do right?