Skip to content

EC2: a launch template's TagSpecifications and IamInstanceProfile are not parsed #471

Closed

Description

@scttfrdmn

Follow-up from #453, which made RunInstances merge a launch template with request-level parameters field by field.

The gap

parseLaunchTemplateData (emulator/ec2_plugin.go) does not parse TagSpecifications or IamInstanceProfile from LaunchTemplateData. So:

  • Tags in a template are silently dropped. An instance launched from a template carrying TagSpecifications comes up untagged. A consumer whose CDK/Terraform stack tags instances through the launch template rather than through RunInstances sees DescribeInstances report no tags, and a tag: filter returns nothing — with no error to explain why.
  • IamInstanceProfile is dropped. The instance reports no profile, so a consumer asserting the role attached to its instances has an assertion that cannot fail.

Because both fields are absent from the parsed structure, #453's per-field precedence matrix has nothing to assert for them: the request's value wins by default rather than by rule, which happens to match AWS's documented precedence but for the wrong reason. If either field is later parsed without the fallback being written, the precedence silently inverts.

Acceptance criteria

  • parseLaunchTemplateData parses TagSpecifications and IamInstanceProfile (both the Arn and Name forms)
  • CreateLaunchTemplate → DescribeLaunchTemplateVersions round-trips both
  • An instance launched from a template carrying TagSpecifications reports those tags from DescribeInstances, and a tag: filter finds it
  • An instance launched from a template carrying IamInstanceProfile reports it in DescribeInstances
  • Per-field precedence, asserted three ways each per EC2: a launch template is ignored entirely when ImageId is also passed #453's matrix: request wins, template fills the gap, neither → the existing default
  • Interaction with EC2: RunInstances and other tag-on-create paths accept reserved aws: tag keys #468 checked: template tags must not become a second unrestricted path for reserved aws: keys
  • docs/services.md — the per-field precedence table gains both rows, and the "not parsed" note is removed

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. One note on why this issue pulled another one into the release with it.

    The read-back criterion was unsatisfiable as written. This issue asked for a
    CreateLaunchTemplate → read-back round-trip, and the natural way to do that is
    DescribeLaunchTemplates. The reference settles that it cannot: the response carries
    only summary fields (createTime, createdBy, defaultVersionNumber,
    latestVersionNumber, launchTemplateId, launchTemplateName) — no launchTemplateData
    at all. DescribeLaunchTemplateVersions is the only operation that returns a template's
    parameters, and substrate did not have it.

    So rather than weaken the criterion to an indirect assertion (launch an instance, infer the
    template's contents from it), #456 came into the release first and the criterion is
    satisfied exactly as written. That is also why the two are sequenced the way they are.

    Two behaviours worth flagging, both of which a consumer can get wrong:

    • Template tags replace rather than merge. A request naming any TagSpecification
      discards the template's entirely, per the general RunInstances rule that "any
      additional parameters that you specify for the new instance overwrite the corresponding
      parameters included in the launch template". The reference gives no
      TagSpecifications-specific merge semantics, so this is the general rule applied — noted
      as such in the comment rather than cited as a per-field statement.
    • Template tags are subject to both tag rules, checked in two places: at
      CreateLaunchTemplate / CreateLaunchTemplateVersion, and again at launch, because a
      template stored before the checks existed can still carry a reserved key. That closes the
      hole this issue specifically warned about — template tags becoming a second unrestricted
      path for aws: keys.

    Volume- and network-interface-scoped template tags remain unmodelled and are documented as
    such rather than silently dropped.

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

    area: ec2fidelitytype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions