Skip to content

ELBv2 listener and listener-rule ARNs are the wrong shape #774

Closed

Description

@scttfrdmn

Substrate mints an ELBv2 listener ARN by appending to the load balancer's own ARN, and a
rule ARN by appending to the listener's:

  • emulator/elb_types.go — elbListenerARN(lbARN, suffix) = lbARN + "/listener/" + suffix
  • emulator/elb_types.go — elbRuleARN(listenerARN, suffix) = listenerARN + "/rule/" + suffix

So substrate produces

arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/web/0abc.../listener/0def...
arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/web/0abc.../listener/0def.../rule/0123...

AWS's published ARNs are flat and carry their own resource type:

arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/web/0abc.../0def...
arn:aws:elasticloadbalancing:us-east-1:123456789012:listener-rule/app/web/0abc.../0def.../0123...

(See the ARN examples in the ELBv2 API reference's Listener and Rule types, and the
resource-ARN table in the ELB user guide's IAM page.)

Why it matters

Two observable consequences:

  1. A policy scoped to a listener or a rule matches nothing. Every AWS-authored
    example writes the Resource of a listener statement as
    arn:aws:elasticloadbalancing:*:*:listener/* and a rule statement as
    …:listener-rule/*. Neither pattern matches substrate's ARN, whose resource type
    segment is loadbalancer. A Deny written that way silently fails to deny.
  2. A consumer parsing the ARN reads the wrong resource type. Anything splitting on
    the sixth colon segment gets loadbalancer/app/web/0abc.../listener/0def... where AWS
    gives listener/app/web/0abc.../0def....

Not covered by #748

#748 added ELB tagging and the elasticloadbalancing:CreateAction second pass. It works
around this rather than fixing it: the tag-on-create pass authorizes against the
AWS-correct type wildcards (listener/*, listener-rule/*), because those are what
a policy is written against, and elbResourceKindFromARN recognises both shapes so a
caller passing a real-shaped ARN to AddTags/DescribeTags is not told it names nothing.
The ARNs substrate mints are unchanged.

Acceptance criteria

  • elbListenerARN and elbRuleARN produce AWS's flat shape, taking the load
    balancer's type/name/id and the listener's id as separate inputs.
  • extractELBNameFromARN / extractELBSuffixFromARN still resolve the state keys
    they resolve today (the listener list is keyed by load-balancer name, and the rule
    list by listener suffix).
  • DescribeListeners' LoadBalancerArn filter and DescribeRules' ListenerArn
    filter still work, neither of which can be derived from the new ARN by prefix.
  • A test asserts a policy scoped to …:listener/* allows ModifyListener and one
    scoped to …:listener-rule/* allows DeleteRule.
  • ## Compatibility records that recorded state and exported fixtures carry the old
    ARNs, and that a consumer asserting a listener ARN verbatim sees it change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions