Files
floci/docs/services
Michal SchreiberandMichal Schreiber dfcd492198 feat(ec2): allow a security group rule to take a prefix list as its source (#2271)
* feat(ec2): allow a security group rule to take a prefix list as its source

AuthorizeSecurityGroupIngress and AuthorizeSecurityGroupEgress now read
IpPermissions.N.PrefixListIds.M, so a rule can name a managed prefix list
instead of a CIDR. The rule carries prefixListId in place of cidrIpv4 and
DescribeSecurityGroups nests the reference under the permission, matching the
shapes AWS returns.

AWS emits one rule per source, so createRules expands a permission across its
CIDRs and its prefix lists rather than treating the two as alternatives; a
permission naming neither still yields the single bare rule it did before. An
unknown list is rejected with InvalidPrefixListID.NotFound before the rule is
stored, so a typo cannot leave a rule pointing at nothing.

Closes #2269

* fix(ec2): resolve every prefix list before writing any security group rule

createRules stored the CIDR rules of a permission before validating its prefix
lists, so a permission naming a valid CIDR alongside an unknown list returned
InvalidPrefixListID.NotFound while leaving the CIDR rule behind. AWS persists
neither, checked against a live account, and rejects the call as a whole rather
than per permission.

Resolve every reference a request names before the first write, across all of
its permissions, so a later bad permission cannot leave an earlier good one
applied. Also brace the new parsing conditional, as AGENTS.md requires.

* style(ec2): brace the conditionals in parseIpPermissions

AGENTS.md is unconditional about braces, and the method held five unbraced
conditionals around the line this branch added. Bracing the whole method rather
than only the new line keeps it internally consistent.

* fix(ec2): scope security group revocation to the sources it names

Revocation compared only protocol and ports, so revoking one source removed
every permission sharing that tuple: revoking a prefix list also dropped a CIDR
rule on the same port. AWS scopes it to the source, verified against a live
account, and leaves the others in place.

Subtract the named sources instead, dropping a permission only once it had
sources and has lost them all. A request naming no source at all still removes
the whole matching permission, which is how a bare protocol and port revoke
behaves.

The permission a revoke names can be the very object authorize stored on the
group, so the source values are snapshotted before either list is mutated.

* fix(ec2): validate prefix lists once per request rather than per permission

Resolving the prefix lists again inside createRules reopened the window the
request-wide check had closed: a list can be deleted between the two, since the
group lock and the prefix list lock are different monitors, so a later
permission could fail after earlier ones had already stored their rules.

Authorize resolves every reference before the first write, so the repeat is
removed. createRules keeps no validation of its own; its other callers pass the
CIDR-only default egress permission.

* fix(ec2): resolve group references when revoking too

Scoped revocation compares the sources a request names against the ones
stored on the permission. Authorize resolves a reference made by group
name to its group id before storing it, so a revoke naming the same
source by name alone carried no id and matched nothing: the rule
survived the revoke that named it.

Resolve on the revoke path as well, mirroring authorize.

This only surfaces once both source-scoped revocation and group
references as a source exist, so the gap is between this branch and
#2266 rather than in either alone.

---------

Co-authored-by: Michal Schreiber <michal.schreiber@benefitsystems.pl>
2026-08-15 13:11:53 -04:00
..
2026-05-10 11:53:31 -05:00
2026-05-10 11:53:31 -05:00
2026-05-10 11:53:31 -05:00
2026-05-10 11:53:31 -05:00
2026-05-10 11:53:31 -05:00
2026-05-10 11:53:31 -05:00