Skip to content

fix(ec2): report an instance's security groups as groupSet (#444) - #449

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/444b-groupset
Aug 1, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/444b-groupset

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #444.

Second and final half of #444. #448 carried the launch-template network interface; this carries the groupSet, and is what makes the template's security groups observable at all.

The defect

RunInstances accepted security groups, validated them against the subnet's VPC, and stored them on the instance (inst.SecurityGroupIDs) — then neither RunInstances nor DescribeInstances emitted them. A consumer that launched an instance with an explicit security group read back an instance with no groups.

Nothing errored. The 200 was correct, the instance was correct, and the fact was simply absent — which reads as "this instance has no security groups" rather than "substrate didn't report them", so the consumer debugs their own code first. Same shape as the rest of this batch: a missing fact, not a missing error.

The fix

Both responses emit groupSet>item with groupId and groupName, matching AWS's GroupIdentifier, for groups from any source — the request, the launch template's network interface, or the default VPC's default group.

groupName is omitted when the group cannot be resolved. A group deleted after the launch keeps reporting its groupId, since that is what the launch actually recorded, rather than being handed an invented name. A fabricated name is the same class of confident-wrong-answer this batch exists to remove.

The two response builders had each declared their own instance item type, which is how a field could go missing from both at once. They now share ec2GroupItem and a single ec2GroupItems helper, so they cannot disagree about the shape.

Tests

TestEC2_Instances_GroupSet asserts both responses in every case — one populated and the other empty is exactly the drift that produced the gap:

Two assertions removed from #448 for being ahead of the code are restored here.

Mutation-tested three ways: removing either emission fails that response's assertions independently; removing the name lookup fails only the four name assertions, leaving the deleted-group case green — so the ID and the name are separately covered.

Verification

gofmt, go build, go vet, golangci-lint run ./... (0 issues), make test (race), test/e2e, make docs-reference-check docs-versions — all clean, re-run after rebasing onto the merged #448.

RunInstances and DescribeInstances accepted security groups on a launch,
validated them against the subnet's VPC and stored them — then omitted them
from every read. A consumer that launched an instance with an explicit
security group read back an instance with no groups at all. Nothing errored;
the fact was simply missing, which reads as "this instance has no security
groups" rather than "substrate didn't report them".

Both responses now emit groupSet>item with groupId and groupName, matching
AWS's GroupIdentifier, for groups from any source: the request, the launch
template's network interface, or the default VPC's default group.

groupName is omitted when the group cannot be resolved. A group deleted after
the launch keeps reporting its groupId, since that is what the launch actually
recorded, rather than being handed an invented name — a fabricated name is the
same class of confident-wrong-answer as the missing field.

The two response builders had each declared their own instance item type,
which is how a field could go missing from both at once. They now share the
group item so they cannot disagree about its shape.
@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 0df25b3 into main Aug 1, 2026
16 checks passed
@scttfrdmn
scttfrdmn deleted the feat/444b-groupset branch August 2, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EC2: launch template NetworkInterfaces is dropped, so template-specified subnets are ignored

1 participant