Skip to content

--vpc is parsed and never read: the instance silently launches in the DEFAULT VPC #673

Closed

Description

@scttfrdmn

Found while fixing #667, by the class gate added with it (TestLaunchFlagsAreWired).

--vpc is bound to the vpcID package global in cmd/launch_flags.go:234, and nothing ever reads it. There is no VPCID field on aws.LaunchConfig at all. Every consumer calls GetDefaultVPC instead:

  • cmd/launch_single.go:1103 (MPI SG) and :1130 (Windows SG)
  • pkg/aws/fsx.go:84 (FSx subnet selection)
  • cmd/app.go:336, cmd/image.go:489

So spawn launch --vpc vpc-0abc... is accepted, exits 0, and launches the instance in the default VPC — with a security group created in the default VPC too.

This is the same shape as #667 but harder to spot, because the identifier looks used: each of those call sites declares its own function-local vpcID, err := awsClient.GetDefaultVPC(...), which shadows the global. A plain grep (or a naive AST identifier count) reads those as uses of the flag variable. The gate in #667 skips any function that declares the name locally, which is what surfaced it.

Why it matters

An account with no default VPC, or one where the research VPC is not the default, cannot target a VPC at all. The failure is silent and the blast radius is network placement: wrong subnet, wrong route table, no route to an EFS/FSx mount target, and SG rules written into a VPC the instance is not in.

Fix sketch

  1. Add VPCID string to aws.LaunchConfig and copy vpcID onto it in buildLaunchConfig (next to the #667 block).
  2. Replace the GetDefaultVPC calls with "use config.VPCID if set, else default".
  3. Subnet selection has to agree: GetSubnetForAZ/GetSubnets must be constrained to the chosen VPC, or an explicit --subnet-id in a different VPC should be a hard error rather than an EC2-level one.
  4. Validate that an explicit --subnet-id and --vpc are consistent, since passing both is the natural way to use this.

Not folded into #667 because step 2/3 changes EFS/FSx subnet resolution, which deserves its own test pass. Listed in knownUnwiredFlags so the gate stays green and the debt stays visible.

Activity

  1. added
    bug
    on Oct 4, 2026
  2. added 2 commits that reference this issue on Oct 5, 2026
    626dd84
    601efba
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions