Skip to content

Use dd-sts for Datadog API keys in workflows - #501

Open
yoannmoinet wants to merge 1 commit into
masterfrom
yoann/migrate-workflows-to-dd-sts-4e60ac13
Open

Use dd-sts for Datadog API keys in workflows#501
yoannmoinet wants to merge 1 commit into
masterfrom
yoann/migrate-workflows-to-dd-sts-4e60ac13

Conversation

@yoannmoinet

@yoannmoinet yoannmoinet commented Sep 2, 2026

Copy link
Copy Markdown
Member

What and why?

Replace every secrets.DATADOG_API_KEY usage in our workflows with a short-lived API key federated from dd-sts (DataDog/dd-sts-action@v1.0.5, GitHub OIDC), removing the long-lived org-wide GitHub secret from CI (SDLC Security initiative). Env var and input names are unchanged (DATADOG_API_KEY / api_key), so no source code changes.

⚠️ Prerequisite: ddoghq/dd-source#79039 must be merged and deployed before this PR merges.

Follow-up once CI is green (repo admin, outside this PR): delete the DATADOG_API_KEY repo secret.

How?

  • ci.yaml: new top-level permissions (contents: read, id-token: write) — this workflow previously had no permissions block at any level, and its checkout needs contents: read — plus a Get Datadog credentials step (id: dd-sts, continue-on-error: true) in each job: before Configure Datadog Test Optimization in unit-test and e2e (fed via api_key), and cache-gated before Build all plugins in lint (same if as the consuming step, so no pointless exchange on a cache hit).
  • publish.yaml / bump.yaml: their jobs already declare the id-token: write permission dd-sts needs at job level (it was there for npm provenance / octo-sts respectively), so only the dd-sts step is added — publish before Publish to NPM (feeding it and Log version published), bump before Log bump.

Every credential step is continue-on-error: true: Datadog telemetry is best-effort, and fork PRs cannot federate an OIDC token, so they keep passing exactly as today. Nothing here can break a build — an empty key makes sendMetrics a no-op, the log-intake curl has no -f, and test-visibility-github-action just exports an empty DD_API_KEY. Security-wise there is no new exposure on pull_request: same-repo PRs already receive secrets.DATADOG_API_KEY today, and dd-sts swaps a static org-wide secret for a short-lived, policy-scoped, audited credential.

Policies validated locally with dd-sts check (schema) and a synthetic claim matrix: each policy accepts only its own event shape (PR / release tag or branch dispatch / master-v2 dispatch) and rejects the other two plus a wrong-workflow claim. Workflows validated with actionlint (no new findings) and yarn cli integrity.

Replace every secrets.DATADOG_API_KEY usage with a short-lived API key
federated from dd-sts (DataDog/dd-sts-action@v1.0.5, OIDC). Env var names
are unchanged downstream so no source code needs to change.

- ci.yaml: top-level permissions (contents: read, id-token: write),
  dd-sts steps before Datadog Test Optimization (unit-test, e2e) and a
  cache-gated one before Build all plugins (lint).
- publish.yaml: dd-sts step before Publish to NPM, feeding both the
  publish and Log version published steps.
- bump.yaml: dd-sts step before Log bump.

All credential steps are continue-on-error so that telemetry stays best
effort and fork PRs, which can't federate a token, keep passing.

Requires the build-plugins-ci, build-plugins-publish and
build-plugins-bump policies to be deployed in dd-source first.
@yoannmoinet
yoannmoinet marked this pull request as ready for review September 2, 2026 21:21
@yoannmoinet
yoannmoinet requested a review from a team as a code owner September 2, 2026 21:21
@yoannmoinet
yoannmoinet requested review from amebosc and removed request for a team September 2, 2026 21:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Workflow changes are narrowly scoped to credential acquisition and key wiring, and all secrets.DATADOG_API_KEY usages in workflows have been removed as intended.

Pull request overview

This PR updates the repository’s GitHub Actions workflows to stop using the long-lived secrets.DATADOG_API_KEY and instead obtain short-lived Datadog API keys via GitHub OIDC using DataDog/dd-sts-action@v1.0.5 (pinned by SHA). This aligns CI/release telemetry with the SDLC security goal of removing org-wide static secrets from automation.

Changes:

  • Add “Get Datadog credentials” (dd-sts) steps to CI, publish, and bump workflows and wire their api_key output into existing DATADOG_API_KEY/api_key inputs.
  • Add top-level workflow permissions in ci.yaml (contents: read, id-token: write) to enable OIDC federation.
  • Replace all remaining secrets.DATADOG_API_KEY references in workflows (verified none remain under .github/workflows/).
File summaries
File Description
.github/workflows/ci.yaml Adds OIDC permissions + dd-sts credential steps and routes api_key into Datadog test visibility and build telemetry env.
.github/workflows/publish.yaml Adds dd-sts step and uses its api_key output for publish and log-intake telemetry.
.github/workflows/bump.yaml Adds dd-sts step and uses its api_key output for bump log-intake telemetry.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

4 participants