Skip to content
AssociateProNACL / Security GroupsAWS VPC

Lab 22: The Security Group With Four Rules That Was Full

A web tier security group with four inbound rules refuses a fifth. The console shows four. The quota is sixty. The error names neither the rule that is in the way nor the number it is counting, and the change that filled the group was the one the review recommended.

Debugging time
~20 min
Reading time
14 min
Reported by
Web Platform
Tier
Associate
INC-1823SEV-3OpenOpened 2026-10-01 10:48 UTC

Cannot add an inbound rule to the web security group; API says the rule limit is reached but the group has four rules

Reported by Web Platform

I need to add one inbound rule to sg-web — HTTPS from a partner's address ranges, which we keep in a prefix list. Terraform refuses it:

Error: creating VPC Security Group Ingress Rule: operation error EC2:
AuthorizeSecurityGroupIngress, https response error StatusCode: 400,
api error RulesPerSecurityGroupLimitExceeded: The maximum number of rules
per security group has been reached.

The group has four inbound rules. I have counted them in the console and with describe-security-group-rules. The quota for rules per security group is sixty, I checked Service Quotas and we are on the default. Nothing is near any limit.

I tried a plain CIDR rule instead of the prefix list to see if it was something about prefix lists. A /16 works. A rule referencing the corporate prefix list, which has three entries in it, is refused with the same error. So I can add some rules and not others, to a group with four rules, and the error says the group is full.

What you are working with

One VPC, one security group, two customer-managed prefix lists, one AWS-managed one. No instances.

Starting state — a security group and the lists its rules reference
VPC 10.220.0.0/16 security group sg-web contains inbound rules , holding 443 from CloudFront, 443 from monitoring, 22 from bastion, ICMP from head office.CloudFront origin-facingAWS-managed prefix listcorporate rangescustomer prefix list, 3 ofmax 8partner rangescustomer prefix list, 3 ofmax 200VPC 10.220.0.0/16security group sg-webinbound rulesprivateRisk — a fifth rule is refused443 from CloudFrontprefix list443 from monitoring10.52.0.0/1622 from bastion10.50.8.0/24ICMP from headoffice10.50.0.0/16

Four inbound rules, drawn as the four things the console shows. Three of them are a CIDR each. The first references the AWS-managed CloudFront prefix list, and how much that one rule counts for is the entire lab. The two customer-managed lists are drawn at their maximum size rather than their current size, for a reason the Reproduction will make clear.

ResourceConfiguration
Security groupsg-web, four inbound rules, one outbound
Rule 1TCP 443 from the AWS-managed com.amazonaws.global.cloudfront.origin-facing prefix list
Rules 2–4TCP 443 from 10.52.0.0/16; TCP 22 from 10.50.8.0/24; ICMP echo from 10.50.0.0/16
Corporate prefix list3 entries, max_entries 8, referenced by nothing
Partner prefix list3 entries, max_entries 200, referenced by nothing
QuotaInbound rules per security group: 60 (default, unchanged)

Nothing is deployed that bills by the hour. The failure is an API refusal, and it is observable with no running resources at all.

Scope and constraints

  • In scope: why a group showing four rules refuses a fifth, and why some fifth rules are accepted while others are refused.
  • Out of scope: the VPC, the quota value itself, and the contents of the prefix lists. All correct.
  • The reporter is right that the group shows four rules and that the quota is sixty. Both are true, and the group is still full. Work out what "full" is measuring.
  • The reporter's experiment — a /16 is accepted, a three-entry prefix list is refused — is the most useful observation in the ticket. It tells you the unit being counted is not "rules".
  • The fix is a sizing decision, and there are two places to make it.

Deploy the broken state

cd lab-22-security-group-prefix-list-quota
terraform init
terraform apply

Under a minute. There are no instances to wait for.