Skip to content

ec2: RunInstances accepts any ImageId, with no InvalidAMIID.NotFound or .Malformed #733

Closed

Description

@scttfrdmn

Found in the live SDK runs for milestone 92 (v0.107.0). RunInstances accepts any
--image-id, including one that names no image and one that is not an AMI ID at all:

$ aws ec2 run-instances --image-id ami-00000000000000000 --count 1 --instance-type t3.micro
{ "Instances": [ { "InstanceId": "i-…", "ImageId": "ami-00000000000000000", … } ] }
$ aws ec2 run-instances --image-id not-an-ami --count 1 --instance-type t3.micro
{ "Instances": [ … ] }

AWS publishes both errors for RunInstances: InvalidAMIID.NotFound ("The specified AMI does
not exist") and InvalidAMIID.Malformed ("The specified AMI ID is not valid. Ensure that you
provide the full AMI ID, in the form ami-xxxxxxxxxxxxxxxxx"). There is also
InvalidAMIID.Unavailable for one that exists but is not usable.

This is the highest-value of the launch-path gaps because AI-generated IaC gets AMI IDs wrong
constantly — a hardcoded region-specific AMI, a stale one, a placeholder — and substrate
currently launches happily from every one of them. A test that should have caught the mistake
passes.

ec2ImageIDKind already exists (emulator/ec2_resourceid.go), and #713 established
ec2RequireResource as the one place a Invalid*.NotFound / Invalid*.Malformed pair comes
from, so the shape of the fix is settled. The care needed is over the launch path's other
image consumers: ec2VolumeFromMapping, the phantom-snapshot fallback #711 pinned, and the
default-AMI behaviour a launch with no ImageId relies on.

Acceptance criteria

  • RunInstances answers InvalidAMIID.Malformed for an ID that is not ami- + 17 hex,
    and InvalidAMIID.NotFound for a well-formed one naming no image, via
    ec2RequireResource(ec2ImageIDKind, …).
  • CreateFleet/RequestSpotInstances and the launch-template paths that name an AMI are
    surveyed in the same pass; each is fixed or listed with the reason it is not.
  • The bundled default AMIs still launch, and a launch that names no ImageId behaves as it
    does today — both pinned.
  • InvalidAMIID.Unavailable is either implemented or documented as out of scope with the
    reason.
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