Skip to content

EC2: the 50-tag-per-resource limit is unmodelled (TagLimitExceeded never fires) #469

Closed

Description

@scttfrdmn

Follow-up from #452.

The gap

TagLimitExceeded appears nowhere in emulator/. Substrate accepts an unbounded number of tags per resource; real EC2 caps it at 50 user tags.

#452 asked that reserved aws: tags not count against the limit. That is vacuously true today because the limit does not exist, which is why #452 shipped without it rather than claiming the exemption works.

The subtle half

Two rules have to land together or the model is wrong in a new way:

  1. Reserved tags are exempt from the count. The EC2 tag-restrictions page states this directly, and it matters here: substrate stamps aws:ec2:fleet-id (EC2: CreateFleet does not apply the aws:ec2:fleet-id tag, so a fleet's instances can't be found #443) on every fleet instance, so a naive counter would let a 50-tag launch template push a fleet instance to 51 and fail a launch real EC2 accepts.
  2. Overwriting an existing key at the limit still succeeds. Real AWS permits updating the value of a key already present on a resource that has 50 tags (reported at EC2 CreateTags throws TagLimitExceeded while updating existing tags getmoto/moto#8151). A check written as len(existing) + len(new) > 50 rejects that; it has to count the post-merge key set.

Acceptance criteria

  • A 51st user tag on CreateTags returns TagLimitExceeded with the real code, message and HTTP status — captured or corroborated, and its provenance stated plainly if it is not from the API model
  • The whole request is refused before any resource is modified, matching EC2: CreateTags accepts reserved aws:-prefixed tag keys that real EC2 rejects #452's all-or-nothing ordering
  • aws:-prefixed tags do not count toward the 50
  • Overwriting the value of an existing key on a 50-tag resource succeeds
  • Tag-on-create paths (RunInstances TagSpecification.N, and see EC2: RunInstances and other tag-on-create paths accept reserved aws: tag keys #468) enforce the same limit, or the ones left out are named with a reason
  • A fleet instance carrying aws:ec2:fleet-id plus 50 user tags is still legal
  • docs/services.md records the limit, the exemption and the overwrite rule

Activity

  1. added this to the v0.86.0 milestone on Aug 2, 2026
  2. scttfrdmn commented on Aug 2, 2026

    @scttfrdmn
    OwnerAuthor

    Shipped in v0.86.0 (#485). One note on provenance, because it differs from #452's in a
    way worth recording.

    TagLimitExceeded is a documented code. EC2's client-error table lists it as "You've
    reached the limit on the number of tags that you can assign to the specified resource."
    That is a stronger claim than #452's reserved-key rejection, whose code came from
    observed responses rather than the reference. Only the wire message here is weaker:
    it is published nowhere, so substrate emits moto's string (The maximum number of Tags for a resource has been reached.) and the code comment says it comes from a
    reimplementation rather than a captured response. Since SDKs dispatch on Error.Code,
    the documented half is the half a consumer's error branch turns on.

    Both of this issue's rules turned out to be one expression rather than two checks —
    the count is over the post-merge key set, excluding aws:-prefixed keys:

    Both are mutation-tested: counting as the sum, and dropping the aws: exemption, each
    fail tests deliberately written to catch them.

    This also closed a gap v0.85.0 had recorded as vacuous — the reserved-tag exemption now
    has a limit to be exempt from.

    Two restrictions from the same table remain unenforced, a key's 128-character maximum and
    a value's 256: #490.

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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions