Repository navigation
fix(launch): security group goes in the --subnet-id's VPC, not the default VPC - #1522
Merged
Merged
Conversation
With --subnet-id in a non-default VPC and no --vpc, the MPI, Windows and
--efa-group security groups were created in the default VPC, and
RunInstances refused every member ('belong to different networks'). Found
live in #1515's egress-proxy test. ResolveLaunchVPC: --vpc, else the
subnet's VPC, else the default VPC; an unreadable subnet fails closed.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Nov 3, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
spawn launch --mpi --subnet-id <subnet in a non-default VPC>, without--vpc, createdspawn-mpi-<name>in the region's default VPC. RunInstances then refused every member:This was found live on 2026-11-03 in #1515's egress-proxy test: aws account, us-east-1, a no-NAT test VPC.
sg-0c15f7f1b7b14ec24is invpc-cd49bfb0(the default VPC), and the subnet is invpc-0a0d97d9dbf34dec7.The Windows SG and
--efa-grouppaths had the same shape. All three calledResolveVPC(ctx, config.Region, config.VPCID), which only knows--vpcand the default VPC. Every earlier MPI test ran in the default VPC, which hid it.Fix
Client.ResolveLaunchVPCresolves the VPC as:--vpc, if given;--subnet-id's VPC, from one DescribeSubnets call;A subnet whose VPC cannot be read fails the launch before anything is created. All three security-group creators now use it. FSx and
SubnetInAZcallResolveVPConly when there is no subnet, so they were already right and are unchanged.Tests
TestLaunchSecurityGroupVPCFollowsTheSubnet: the real client against an httptest EC2 fake. It covers explicit--vpc, the subnet's VPC, the default VPC, and an unreadable subnet, which fails closed.TestLaunchSecurityGroupCreatorsUseTheSubnetAwareVPC: a source gate. No non-test file incmdmay callResolveVPC(ctx, config.Region, config.VPCID), and the 3 creators must useResolveLaunchVPC.ResolveVPCmakes the gate fail, naminglaunch_single.go.make checkand semgrep pass. Additive public API:ResolveLaunchVPC, snapshot regenerated. IAM:ec2:DescribeSubnetsis already in every launch path.Refs #1515