Skip to content

Default VPC, subnet and security-group ids are identical in every region #21

Closed

Description

@lex00

Ec2Service.ensureDefaultResources(region) stores per region correctly — key(region, vpcId) — but assigns the same id strings everywhere:

String vpcId = "vpc-default";
String[] subnetIds = {"subnet-default-a", "subnet-default-b", "subnet-default-c"};

So a three-region account exposes:

us-east-1   vpc=vpc-default  subnets=subnet-default-a, -b, -c
us-west-1   vpc=vpc-default  subnets=subnet-default-a, -b, -c
us-west-2   vpc=vpc-default  subnets=subnet-default-a, -b, -c

sg-default behaves the same way.

Real AWS never does this. VPC, subnet and security-group ids are globally unique; two regions' default VPCs have different ids. Any consumer that keys a resource by its id — the normal thing to do, since the id is the identifier — collapses three distinct resources into one.

Why it matters beyond cosmetics

It silently changes answers to questions that count resources across regions. Found while measuring a tool that snapshots an account: nine default subnets across three regions replayed as three, and a question asking how many subnets are empty came back 2 instead of 8. Nothing errored. The tool behaved correctly for ids that, on real AWS, could not have collided.

Anything aggregating account-wide is exposed: resource counts, drift detection, cost attribution, "what exists where".

Suggested fix

Derive the ids per region so they stay recognisable but unique — vpc-default-us-east-1, subnet-default-us-east-1-a — or hash the region into an AWS-shaped id. A helper (defaultVpcId(region)) would keep the four call sites in Ec2Service and the one in RdsService consistent.

Worth checking other services that seed defaults for the same pattern before fixing only EC2.


Originally filed upstream by mistake (floci-io#2097) and closed there — nothing goes upstream without a fix delivered alongside it.

Activity

  1. lex00 commented on Aug 18, 2026

    @lex00
    OwnerAuthor

    Still current on main. Ec2Service lines 326, 341, 359, 1521, 1534, 2302, 4062 all hardcode vpc-default/subnet-default-*/sg-default. No per-region derivation yet.

  2. lex00 commented on Aug 18, 2026

    @lex00
    OwnerAuthor
  3. added a commit that references this issue on Aug 19, 2026
    337dead
  4. lex00 commented on Aug 19, 2026

    @lex00
    OwnerAuthor

    Merged upstream: floci-io#2384

  5. added a commit that references this issue on Sep 1, 2026
  6. added
    upstream
    on Oct 21, 2026
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

    upstream

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions