Skip to content

feat: read cache tokens from SSM with the job OIDC token - #4

Merged
dohernandez merged 1 commit into
mainfrom
feat/ssm-tokens
Nov 10, 2026
Merged

dohernandez merged 1 commit into
mainfrom
feat/ssm-tokens

Conversation

@dohernandez

@dohernandez dohernandez commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

What

  • support/scripts/read-ssm-token.sh ROLE REGION PARAMETER OUT: requests the job's GitHub OIDC token (audience=sts.amazonaws.com), aws sts assume-role-with-web-identity (token from a file), aws ssm get-parameter --with-decryption with the temporary credentials in the environment, refuses an empty or CHANGE_ME value, masks every secret and writes the value to a 0600 file. Exit 3 = the job has no OIDC token. Nothing secret on argv.
  • nix-setup: cache_pull_token_ssm_parameter, aws_role_arn, aws_region. A read failure warns and builds from source, like a bad token.
  • nix-cache-push: token_ssm_parameter, aws_role_arn, aws_region. A read failure is a failed upload (warning, or error with verify).
  • Both: setting the token and the SSM parameter is an error; the SSM parameter without a role is an error; no OIDC token fails the job (missing id-token: write) unless it is a fork's pull request, which keeps today's behaviour (push skipped, pull warns). The existing token inputs are unchanged.
  • docs/using/actions.md: the new inputs and notes.

Tests

Step scripts extracted with yq and run with stub curl / aws / nix / attic:

Case Result
helper: no OIDC env / ok / OIDC fails / assume fails / read fails / placeholder 3 / 0 (value, mode 600) / 1 / 1 / 1 / 1
helper: secrets in argv 0 hits (request token, OIDC JWT, keys, value)
nix-setup: SSM ok netrc holds the token; temp file removed
nix-setup: token + SSM / SSM without role / no OIDC same repo error
nix-setup: no OIDC fork PR / read fails warning, no netrc, exit 0
nix-setup: plain token unchanged
push: SSM ok + verify attic logs in with the SSM token, verified 1 path(s)
push: fork no OIDC / same repo no OIDC skip exit 0 / error exit 1
push: read fails default / verify warning exit 0 / error exit 1
push: token + SSM error; plain token + verify unchanged

shellcheck clean (SC2164 on the existing cd excluded); nix flake check pass.

The whole change (apply in this order)

Why: the CI push token for nix-cache.ygr.ai was a 90-day attic JWT pasted by hand into three repository secrets (genlayer-node, genlayer-consensus, genvm-manager). Nothing rewrote it; it expired about 1 Nov 2026 and every push was refused for a week behind a warning (now made visible by verify, github-actions#3). This set makes the cache host mint and rotate every CI token into SSM, and CI read its own tokens in-job through a per-repository OIDC role.

  1. genlayerlabs/devexp-tf-secrets#65 — SSM placeholders /devexp-dev/nix-cache/ci-tokens/<repo>-{pull,push} for genlayer-node, genlayer-consensus, genvm-manager.
  2. genlayerlabs/devexp-tf-infra#162 — the cache host's role may read and overwrite those parameters (and the two e2e runner pull tokens); one OIDC role github-oidc-<repo>-nix-cache-tokens per repository, reading only its own pair.
  3. genlayerlabs/devexp-nix-cache#4 — systemd timer on the host: mints each token with atticadm and the server key, checks it against the running server, writes it to SSM when the parameter is a placeholder or older than 30 days (tokens valid 90 days). Runs 2 min after deploy/boot, then daily. Also rotates the e2e runner pull tokens, which the runners already read from SSM at job start.
  4. feat: read cache tokens from SSM with the job OIDC token #4 — opt-in inputs: nix-setup cache_pull_token_ssm_parameter, nix-cache-push token_ssm_parameter, both with aws_role_arn. The token inputs keep working.
  5. genlayerlabs/genlayer-node#2398 and genlayerlabs/genlayer-consensus (PR in progress) — workflows switch to the SSM inputs. Merge only after 1-4 are applied and the parameters hold tokens.

After 5: delete the NIX_CACHE_PULL_TOKEN / NIX_CACHE_PUSH_TOKEN repository secrets. genvm-manager has its role and tokens from 1-3; its workflows still use the secrets (its own wrapper action pins an old commit) and need the same switch by its owners.

Note for review: devexp-nix-cache docs/using/ci.md recorded the opposite choice ("no OIDC role per repo just to read a string"). The trade changes because a secret nobody rewrites expires unnoticed; the GitHub-secret path stays supported.

nix-setup and nix-cache-push accept an SSM parameter and an IAM role instead of a token: the job exchanges its GitHub OIDC token for the role and reads the token the cache host keeps fresh. The token inputs keep working unchanged.
@coderabbitai

coderabbitai Bot commented Nov 9, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8fe0c5c7-141a-450b-8725-e194878b969e
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dohernandez
dohernandez merged commit 96ecc5c into main Nov 10, 2026
2 checks passed
@dohernandez
dohernandez deleted the feat/ssm-tokens branch November 10, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants