Skip to content

[audit] Dup: per-region EC2 client boilerplate repeated ~43+ times in pkg/aws — add c.regionalEC2(region) #297

Closed

Description

@scttfrdmn

Filed from the 2026-07-11 spawn audit. Full report: docs/spawn-audit-2026-07-11.md. Assessment-only — no code changed yet.

Phase: Phase 0 — do now (dup)

Evidence

  • pkg/aws: 47 ec2.NewFromConfig sites, 43 cfg.Copy() sites
  • getRegionalConfig (pkg/aws/client.go:1924) returns (cfg,nil) — its error is ALWAYS nil, so every if err != nil branch after it is dead

Recommendation
Add a c.regionalEC2(region) helper; retire getRegionalConfig and kill the dead error branches it spawned.

User-facing / SemVer: No — internal. No bump.

Adversarially verified during the audit (62/62 findings survived verification; severities/scope adjusted where the first pass was wrong).

Activity

  1. added
    audit:2026-07
    on Jul 11, 2026
  2. scttfrdmn commented on Jul 11, 2026

    @scttfrdmn
    ContributorAuthor

    Deferred from the Phase 0/1 cleanup batch (PR #331). This spans 40+ ec2.NewFromConfig/cfg.Copy() sites across pkg/aws on the launch/describe hot path, and the finding itself rated it optional ("do when touching files"). Bundling it with the small dup cleanups would have made #331 hard to review and risky. Keeping it open as its own focused PR — the c.regionalEC2(region) helper + retiring getRegionalConfig (whose error is always nil, so its callers have dead if err != nil branches to remove too).

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

    audit:2026-07

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions