Skip to content

RunInstances response omits tagSet for launch-time TagSpecifications #351

Closed

Description

@scttfrdmn

Problem

RunInstances does not return a tagSet for tags applied at launch via TagSpecifications, even though the instance stores them correctly (a subsequent DescribeInstances renders them fine). Real EC2 does populate Instances[].Tags in the RunInstances response for launch-time tags, so SDK callers that read the returned instance's tags get an empty set against substrate but a populated one against AWS — a fidelity gap.

Reproduction (v0.72.0)

curl -s -X POST http://localhost:4566/ \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Authorization: AWS4-HMAC-SHA256 Credential=test/.../ec2/aws4_request" \
  -d "Action=RunInstances&Version=2016-11-15&MinCount=1&MaxCount=1&InstanceType=c6a.xlarge&ImageId=ami-12345678&TagSpecification.1.ResourceType=instance&TagSpecification.1.Tag.1.Key=Name&TagSpecification.1.Tag.1.Value=echo-test&TagSpecification.1.Tag.2.Key=spawn:managed&TagSpecification.1.Tag.2.Value=true"
# RunInstancesResponse has NO <tagSet> on the instance item

# but the tags ARE stored:
curl ... -d "Action=DescribeInstances&Filter.1.Name=tag:Name&Filter.1.Value.1=echo-test"
# DescribeInstancesResponse DOES contain <tagSet>…</tagSet>

Root cause

In emulator/ec2_plugin.go, runInstancesResponse (~line 446) defines a local ec2InstanceItem struct that has no tagSet field, and the population loop never copies inst.Tags:

type ec2InstanceItem struct {
    InstanceID       string `xml:"instanceId"`
    // …ImageID, InstanceType, State, etc.
    // (no Tags field)
}

Contrast the DescribeInstances item type (~line 591), which already has:

Tags []tagItem `xml:"tagSet>item"`

and renders correctly.

Suggested fix

Add the same tagSet field to the RunInstances item struct and populate it from inst.Tags in the build loop (the data is already on the EC2Instance), mirroring the DescribeInstances renderer. RunInstances, StartInstances, and StopInstances responses on real EC2 all echo the instance's tagSet — worth checking the stop/start responses for the same omission while in there. Happy to send a PR.

Impact / context

Found building spawn-ts (browser EC2 launcher; consumer of substrate via the CORS support added in #346). Its RunInstances wrapper built the launched instance's view from the response and got zero tags back, so all lifecycle config (TTL/idle/cost, decoded from spawn:* tags) was silently empty on the returned object until a re-describe. I worked around it on my side by trusting the tags I sent, but the response should match AWS. The integration test that caught it:

  • RunInstancesResponse should include <tagSet> with every tag from the launch's TagSpecification entries whose ResourceType=instance.

Environment: substrate v0.72.0, EC2 API version 2016-11-15.

Activity

  1. scttfrdmn commented on Jul 20, 2026

    @scttfrdmn
    OwnerAuthor

    Verified the fix on 784f9af: RunInstances now returns the <tagSet> inside the instance item, matching real EC2:

    ...<instanceState><code>16</code><name>running</name></instanceState><tagSet><item><key>Name</key><value>echo-test</value></item><item><key>spawn:managed</key><value>true</value></item></tagSet>...
    

    Also checked the Stop/Start responses I mentioned above: real EC2's StopInstances/StartInstances return only currentState/previousState per instance and no tagSet, and substrate matches that — so there's no equivalent gap there. Confirmed against spawn-ts's integration suite. Thanks for the quick turnaround; leaving this to close on the next tagged release.

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions