Skip to content

EC2 GitHub Runner Hardening & Modernization Plan (tracker) #15

@kurok

Description

@kurok

Tracker for a multi-phase effort to modernize and harden namecheap/ec2-github-runner for production-grade usage. Child issues listed below; this one stays open until every phase is landed.

Overview

This action is the critical supply-chain link between every self-hosted CI pipeline in the org and AWS. Current state has known issues:

  • Legacy node12 runtime (fixed via feat: declare action runtime as node24 #4 but more dep modernization needed).
  • aws-sdk v2 (in maintenance mode, emits DEP0169).
  • Long-lived static AWS keys recommended as default.
  • Classic GitHub PAT recommended as default.
  • Runner binary version hardcoded; no configurable override.
  • Runner runs as root (RUNNER_ALLOW_RUNASROOT=1).
  • Best-effort cleanup (no retries, no bounded timeouts).
  • Ad-hoc logging; no debug mode.
  • Zero unit tests.

Goals

  1. Eliminate long-lived credentials.
  2. Enforce ephemeral runner model.
  3. Apply least-privilege IAM.
  4. Modernize runtime and dependencies.
  5. Improve lifecycle reliability and cleanup.
  6. Reduce operational toil.
  7. Provide scalable and secure defaults.

Phases

Compatibility with the primary consumer (terraform-provider-namecheap acceptance tests)

Phase Breaks acctest? Notes
1 (aws-sdk v3) No — if input/output contract preserved Regression verified via dogfood SHA-pin rotation
2 (OIDC) No (opt-in) Provider repo keeps working on static keys; cross-repo migration separate
3 (token types) No (opt-in) Classic PAT stays accepted; docs change only
4 (non-root + --ephemeral) Medium risk make testacc = plain go test, setup is workspace-local — no root needed. But deserves a dogfood push to confirm
5 (lifecycle) No Strict improvement
6 (secure defaults) No Provider's existing SG + EIP + AMI continue to work; IMDSv2 is transparent to aws-sdk / SSM
7 (logging) No Output-only change
8 (tests) No Build-side

Phase 4 is the only place where a dogfood SHA-pin rotation on a terraform-provider-namecheap throwaway branch is strongly recommended before the underlying PR lands on feat/al2023-support.

Already-landed groundwork

Not part of the plan formally but relevant context:

Suggested ordering

  1. Phase 1: complete runtime & dependency upgrade (aws-sdk v2 → v3, ncc modernization) #7 first — aws-sdk v3 + ncc bump is the prerequisite for any further dep modernization (including @actions/core ≥ 1.10 which the current ncc can't parse).
  2. Phase 8: unit tests for config, AWS params, and GitHub flow #14 in parallel — unit tests give confidence for every subsequent refactor.
  3. Phase 4: bootstrap hardening — non-root runner user, --ephemeral, configurable runner version #10 — bootstrap hardening touches source that Phase 1: complete runtime & dependency upgrade (aws-sdk v2 → v3, ncc modernization) #7 already refactored; landing Phase 1: complete runtime & dependency upgrade (aws-sdk v2 → v3, ncc modernization) #7 first keeps the diff smaller.
  4. Phase 5: lifecycle & cleanup reliability — retries, timeouts, always-cleanup #11 — lifecycle retries build on Phase 4: bootstrap hardening — non-root runner user, --ephemeral, configurable runner version #10's ephemeral foundation.
  5. Phase 7: structured logging + debug mode #13 — logging changes read easier once Phase 1: complete runtime & dependency upgrade (aws-sdk v2 → v3, ncc modernization) #7's SDK rewrite is in place.
  6. Phase 6: secure defaults — IMDSv2, encrypted EBS, subnet/SG guidance #12 — secure defaults (code side) and Phase 2: support GitHub OIDC for AWS credentials #8 (OIDC docs + optional role-to-assume input) can land any time; no dependency.
  7. Phase 3: recommend GitHub App token / fine-grained PAT over classic PAT #9 — token-type docs any time; no dependency.

Total estimated effort: 5–7 working days per the plan author.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions