Repository navigation
Description
Discovered while implementing #453.
The gap
RunInstances records UserData, and #453 added the launch-template fallback for it, so an instance launched from a template now carries the template's user data. Nothing can read it back. DescribeInstanceAttribute is not implemented, and no other operation exposes the field, so:
- A consumer cannot assert that the user data their IaC intended reached the instance.
- EC2: a launch template is ignored entirely when ImageId is also passed #453's
UserDataprecedence fallback is untestable through the public API — it is asserted only indirectly, which means it could regress silently.
DescribeInstanceAttribute is the operation AWS provides for this (Attribute=userData returns it base64-encoded), and it covers a family of other attributes on the same surface: instanceType, kernel, ramdisk, disableApiTermination, instanceInitiatedShutdownBehavior, rootDeviceName, blockDeviceMapping, sourceDestCheck, groupSet, ebsOptimized, sriovNetSupport, enaSupport, enclaveOptions, disableApiStop.
Its companion ModifyInstanceAttribute is what a consumer uses to change user data on a stopped instance, and is absent too.
Scope note
Per CLAUDE.md's boundary: this is about making the recorded input observable through an API call, not about executing it. Substrate does not run user data or cloud-init and should not — the value is recorded intent, and reporting it back is exactly the observable half.
Acceptance criteria
-
DescribeInstanceAttributewithAttribute=userDatareturns the recorded value, base64-encoded, in the documented{ InstanceId, UserData: { Value } }shape - The response shape for an attribute that was never set matches AWS (an empty
<value/>element rather than an omitted one, verified against the reference) - An unsupported or missing
Attributereturns the documented error, not a 200 -
Attribute=instanceType,groupSetanddisableApiTerminationare covered as well, since they read state substrate already holds - A
RunInstancesthat took itsUserDatafrom a launch template reports the template's value — the EC2: a launch template is ignored entirely when ImageId is also passed #453 assertion this issue exists to make possible -
ModifyInstanceAttributeforuserDataon astoppedinstance, and theIncorrectInstanceStateerror on arunningone, or a note deferring it with a reason -
docs/services.mdcoverage matrix updated
Activity
scttfrdmn commentedon Aug 2, 2026
Shipped in v0.86.0 (#486). Three notes, one of them a criterion this issue asked to have
verified and which cannot be from the reference.
The empty-attribute shape has weaker provenance than the rest. This issue asked that
an unset attribute's shape be checked against the reference. All three of the reference's
worked examples show an attribute that has a value, so the reference does not settle it.
The shape ships from moto's
test_describe_instance_attribute, which assertsresponse["UserData"] == {}— an empty mapping, i.e. a present element with no children,so
<userData></userData>on the wire rather than an omitted element. That is areimplementation's test rather than a capture, and it is labelled as such in both the code
comment and
docs/services.md. The distinction is not cosmetic: an SDK maps apresent-but-empty element to an empty struct and an omitted one to nil, so
resp.UserData.Valuepanics under one and not the other.The unknown-attribute error, by contrast, has the strongest provenance in the release.
Value (enaSupport) for parameter attribute is invalid. Unknown attribute.is capturedfrom real AWS in aws/aws-cli#4273 and is byte-identical to moto's string — a capture and an
independent reimplementation agreeing. The reference could not have supplied it; its Errors
section is empty.
enaSupportis the case that makes the boundary concrete: it is in AWS'sown valid-values list while the same page says the attribute "is not supported", and #4273
captures exactly that rejection. So substrate refusing the twelve unmodelled attributes is
fidelity, not a shortfall — answering
sourceDestCheckwith a defaultfalsewould beindistinguishable from a real instance that has it disabled.
One finding changed the plan. The stopped-state gate on
ModifyInstanceAttributecovers
userDataandinstanceType— the latter a behaviour change, since substratepreviously changed a running instance's type — but not
disableApiTermination.RunInstances' reference says protection can be enabled "when you launch an instance,while the instance is running, or while the instance is stopped", so gating it would refuse
a call real EC2 accepts. That is the same class of defect as accepting one real EC2
refuses, just in the other direction and harder to notice, because it looks like extra
rigor. There is a test pinning the exemption.
Also worth recording: writing the wire-shape test caught a bug no struct decoder could
see. Go's
encoding/xmlemits the parent element of ana>bpath even for an emptyslice, so a
groupSet>itemfield put<groupSet></groupSet>in every response — acaller asking for
userDatawas told the instance had no security groups. Fixed with anil-able wrapper and pinned from both directions.
Termination protection is now recorded and reported but still not acted on:
TerminateInstancesterminates a protected instance, where real EC2 refuses withOperationNotPermitted. That is #489.fix(ec2): TerminateInstances honours termination protection (#489) (#504