Skip to content

EC2: a launch template is ignored entirely when ImageId is also passed #453

Closed

Description

@scttfrdmn

What

runInstances gates its whole launch-template block on imageID == "". A request that supplies both an explicit ImageId and a LaunchTemplate.LaunchTemplateId therefore never reads the template at all — losing its InstanceType, KeyName, security groups, and (as of #444) its subnet and public-IP preference.

Real AWS merges the two, with request-level values winning per field. The launch succeeds either way, so this is the same shape as #443/#444: no error, just a silently different instance than the caller asked for.

Why it was not fixed inside #444

Widening the gate changes behaviour for every existing caller that passes both, in a way that depends on which fields their template carries. It needs its own per-field precedence matrix and test table rather than riding along on a subnet fix.

Acceptance criteria

  • Template resolution no longer depends on whether ImageId was supplied.
  • Precedence asserted per field, request-level winning: ImageId, InstanceType, KeyName, SubnetId, security groups, AssociatePublicIpAddress, IamInstanceProfile, tags.
  • A field absent from the request but present in the template is taken from the template.
  • A field absent from both falls back to the existing default (default VPC, t3.micro, etc.).
  • The RunInstances: validate required parameters (ImageId) like AWS does #412 MissingParameter behaviour is unchanged: the AMI check still runs after template resolution.
  • Existing launch-template tests still pass — TestEC2Plugin_RunInstances_ViaLaunchTemplate and the ec2_launchtemplate_test.go suite are the regression surface.
  • docs/services.md states the merge rule and the per-field precedence.

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