Skip to content

feat(elb): the listener and rule ARN shape AWS publishes (#774) - #823

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/774-elb-listener-arns
Sep 12, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/774-elb-listener-arns

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

A listener and a listener rule are siblings of their load balancer's ARN, not children of
it. Substrate nested them, so …:listener/* — the wildcard every AWS policy example writes —
matched nothing at all: a Deny written the documented way silently failed to deny, and an
Allow on …:loadbalancer/* was a prefix of every listener and rule ARN and reached them both.

AWS's shape, from its Service Reference Information document for elasticloadbalancing
(Version v1.4):

listener/app       arn:…:listener/app/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}
listener-rule/app  arn:…:listener-rule/app/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}/${ListenerRuleId}
loadbalancer/app/  arn:…:loadbalancer/app/${LoadBalancerName}/${LoadBalancerId}

The child repeats the load balancer's name and id inside its own resource type. That document is
now vendored at emulator/authzref/elasticloadbalancing.json beside the EC2 and IAM snapshots
(elasticloadbalancing added to cmd/gen-authz-reference's services, the only gate), so the
tests substitute the placeholders in AWS's own templates and compare against the minted ARN —
a drift on either side fails, where a template copied into a test can only agree with the
implementation it was copied from. The generated tables are read by ec2_authz.go and by tests
only, so vendoring a third service is inert for behaviour.

A second divergence, found by that join and fixed here because it is the same defect: a load
balancer's ARN carried LoadBalancerTypeEnum's value (application) where AWS's ARN carries the
abbreviation (app/net/gwy). A listener ARN repeats its load balancer's subtype, so leaving
the long form would have minted listener/application/… and left listener/app/* matching
nothing — the very failure being fixed.

CreateListener and CreateRule now answer ValidationError/400 when the parent ARN cannot
yield a child (malformed, or the classic-ELB …:loadbalancer/<name> form, which has too few
segments). Minting a child of the wrong arity would reproduce the defect from the other side.

The old nested spelling stays recognised on the tagging path: an event log or exported fixture
recorded by an earlier version carries those ARNs, and a replay whose tagging calls named no
resource would defeat the property the event store exists to provide. Nothing mints it any more.

Fail-before

With the nesting builders and the long subtype restored, 4 tests fail (6 subtests):
TestELB_AListenerAndRuleARNMatchTheFormatAWSPublishes,
TestELB_AnARNCarriesAWSsTypeAbbreviation (all three arms),
TestELB_AMalformedParentARNIsRefusedRatherThanMintingAMalformedChild. Restored: green.

Tests

New emulator/elb_arn_shapes_test.go — the minted ARNs against AWS's published formats with the
placeholders substituted; the subtype abbreviation looked up in the snapshot rather than asserted
as a literal; a malformed and a classic-ELB parent refused; a policy scoped to …:listener/*
allowing ModifyListener and one scoped to …:listener-rule/* allowing DeleteRule, a
rule-scoped Deny that now actually denies without spilling onto listeners, and a
loadbalancer/* grant that no longer reaches either child; DescribeListeners' and
DescribeRules' filters pinned (they compare the child's stored parent ARN and never depended
on the nesting); AddTags/DescribeTags round-tripping a new-shape ARN while both spellings
still resolve.

Compatibility

ELBv2 listener, listener-rule and load-balancer ARNs change shape. A consumer asserting one
verbatim sees it change, and a policy scoped to loadbalancer/* that used to catch listeners no
longer does — which is what AWS does. Recorded state and exported fixtures carrying the old ARNs
still resolve on the tagging path.

Closes #774

A listener and a listener rule are siblings of their load balancer's ARN,
not children of it. Substrate nested them, so `…:listener/*` — the wildcard
every AWS example writes — matched nothing, and the load balancer's own ARN
was a prefix of both.
@scttfrdmn scttfrdmn added this to the v0.113.0 milestone Sep 12, 2026
@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.11111% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/elb_plugin.go 66.66% 4 Missing ⚠️
emulator/elb_types.go 95.83% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 2e98b8a into main Sep 12, 2026
16 of 17 checks passed
@scttfrdmn
scttfrdmn deleted the feat/774-elb-listener-arns branch September 12, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ELBv2 listener and listener-rule ARNs are the wrong shape

1 participant