Repository navigation
Description
What's missing
Real EC2 tags every instance launched by a fleet with a reserved
aws:ec2:fleet-id tag whose value is the fleet ID. Substrate's CreateFleet
(0.82.0, #387) launches the instances correctly but does not apply that tag, so
there is no way to get from a fleet ID back to its instances.
launchFleetPool (emulator/ec2_fleet.go:429) forwards only the caller's own
TagSpecification entries:
ids, launchErr := p.launchFleetPool(reqCtx, pool, gotPerPool[i], instanceTags)where instanceTags := passthroughFleetTagSpecs(req.Params, "instance")
(ec2_fleet.go:278). Nothing adds the AWS-injected tag. grep -rn "fleet-id" emulator/*.go
returns nothing.
Why it matters
For an instant fleet, the fleet-id tag is the only supported way to enumerate
current instances. The two obvious alternatives don't work on real AWS:
DescribeFleetInstancesrefuses an instant fleet outright:Unsupported — "Describe fleet instances is not supported by this type of fleet."DescribeFleetsreturns anInstanceslist, but it only reflects the original
launch — it does not drop instances that have since terminated.
So callers that need "what is this fleet still running" filter
DescribeInstances on tag:aws:ec2:fleet-id. That's what
parsl-aws-provider's
get_ec2_fleet_instance_ids() does, and it's the basis of its fleet status
polling — an active instant fleet's FleetState stays active for the fleet's
whole life regardless of what became of the instances, so instance state is the
only real signal.
Against substrate the lookup returns empty, which reads as "the fleet's
instances are all gone" — the opposite of the truth, and a status of COMPLETED
for a fleet that is fully provisioned and running.
Reproduction
import boto3
ec2 = boto3.client("ec2", endpoint_url="http://localhost:4566",
region_name="us-west-2",
aws_access_key_id="x", aws_secret_access_key="y")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]["VpcId"]
az = ec2.describe_availability_zones()["AvailabilityZones"][0]["ZoneName"]
sn = ec2.create_subnet(VpcId=vpc, CidrBlock="10.0.0.0/24", AvailabilityZone=az)["Subnet"]["SubnetId"]
lt = ec2.create_launch_template(LaunchTemplateName="t",
LaunchTemplateData={"ImageId": "ami-12345678", "InstanceType": "t3.micro"})["LaunchTemplate"]
f = ec2.create_fleet(
Type="instant",
LaunchTemplateConfigs=[{
"LaunchTemplateSpecification": {"LaunchTemplateId": lt["LaunchTemplateId"], "Version": "1"},
"Overrides": [{"InstanceType": "t3.micro", "SubnetId": sn}],
}],
TargetCapacitySpecification={"TotalTargetCapacity": 2, "DefaultTargetCapacityType": "spot"},
)
fid = f["FleetId"]
ids = [i for g in f["Instances"] for i in g["InstanceIds"]]
d = ec2.describe_instances(InstanceIds=ids)["Reservations"][0]["Instances"][0]
print("tags:", d.get("Tags")) # observed: [] expected: aws:ec2:fleet-id=<fid>
found = ec2.describe_instances(
Filters=[{"Name": "tag:aws:ec2:fleet-id", "Values": [fid]}])["Reservations"]
print("found:", sum(len(r["Instances"]) for r in found)) # observed: 0 expected: 2Observed on ghcr.io/scttfrdmn/substrate:0.82.0:
tags: []
found: 0
moto 5.1.21 has the same gap, for what it's worth — this isn't a
substrate-vs-moto regression, just something neither emulates.
Suggested fix
In launchFleetPool, add the tag alongside the passthrough ones, using the same
TagSpecification.N.* encoding it already builds for RunInstances. The fleet ID
has to be generated before the launch loop for this (it currently is —
fleet.FleetID = generateFleetID() at ec2_fleet.go:283, before the
for i, pool := range pools loop), so it's available to pass down.
Worth confirming CreateTags also permits the reserved aws: prefix only where
AWS does. Substrate currently accepts create_tags(Tags=[{"Key": "aws:ec2:fleet-id", ...}])
from a client, which real EC2 rejects with
InvalidParameterValue: Tag keys starting with 'aws:' are reserved for internal use.
That's a separate (smaller) fidelity gap, and it's the workaround this project
uses in the meantime, so no rush on tightening it.
Related
- EC2: no CreateFleet handler (partial-fulfillment semantics are the interesting part) #387 added
CreateFleet - RunInstances response omits tagSet for launch-time TagSpecifications #351 (
RunInstancesresponse omittedtagSet) and DescribeInstances only reads Filter.1 and only honors instance-state-name — multi-filter and tag: filters silently dropped #305 (tag:filters) are
the nearest neighbours; both are fixed, and this test depends on both working.
Activity
scttfrdmn commentedon Aug 1, 2026
Fixed in #447, shipping in v0.84.0.
CreateFleetnow stampsaws:ec2:fleet-idon every instance it launches, so yourget_ec2_fleet_instance_ids()works against aDescribeInstancestag:aws:ec2:fleet-idfilter with no workaround.Your diagnosis of why it mattered is what settled the priority: for an
instantfleet there is no other route.DescribeFleetInstancesrejects instant fleets outright, and thefleetInstanceSeta fleet response echoes is a record of what was launched rather than what is running — it never drops terminated instances. So a fully-provisioned fleet read as empty.The tag survives alongside your own launch-time
TagSpecificationentries (neither overwrites the other — that was the specific regression the index arithmetic could introduce, and it's pinned by a test), and is applied per capacity pool, so a multi-pool fleet tags all of its instances.One thing you should know about the evidence, since it affects how much you should trust this. I could not find
aws:ec2:fleet-iddocumented anywhere authoritative: it is not in the EC2 API model, and the fleet tagging/describe/delete user-guide pages are silent on reserved tags — they say only that user tags are not auto-applied. So substrate implements this on your observed real-AWS behaviour, not on a documented API contract. The code comment, the CHANGELOG anddocs/services.mdall say so explicitly rather than implying a citation. If you ever see real AWS use a different key, that's a bug report worth filing — substrate would be wrong, not just undocumented.Also worth acting on now: substrate currently accepts
CreateTagswith anaws:-prefixed key, which real EC2 rejects (InvalidParameterValue: Tag keys starting with 'aws:' are reserved for internal use). That's a genuine gap on our side, filed as #452. I deliberately did not tighten it in this release, because applying the tag by hand is your current workaround and removing it in the same release that makes it unnecessary would have broken you with no overlap window. It will be tightened a release later — so drop the manual tagging when you pick up v0.84.0 rather than discovering the rejection later.chore(release): v0.84.0 (#451)
feat(ec2): reject reserved aws:-prefixed tag keys (#452) (#463)
feat(ec2): enforce the 50-tag-per-resource limit (#469) (#479)
fix(ec2): carry a launch template's tags and instance profile to the …