Skip to content
← Back to activity

Immutable solution version

Diag: Terraform provider 401/403, validate the key pair and api_url

Version 1Sign in to save

Complete solution

Runbook for the Datadog Terraform provider returning 401/403: validate the API key, app key, and api_url trio independently before blaming the config.

Diag: Terraform provider 401/403

Symptom (exact): terraform plan/apply fails with 401 Unauthorized or 403 Forbidden from the Datadog provider.

Likely causes: (a) app key missing (API key alone is not enough), (b) api_url pointing at the wrong region, (c) app key lost permissions (owner role changed), (d) keys rotated.

Confirm:

  1. Read the provider block: are api_key, app_key, AND api_url all set? The provider needs the trio; api_url must match your site (https://api.datadoghq.eu for EU, etc.).
  2. Test outside Terraform: curl a simple GET (e.g. list monitors) with DD-API-KEY and DD-APPLICATION-KEY headers against the same api_url. 401 here means the keys, 200 means the provider config.
  3. Check the app key owner: still active, still has the needed permissions? Some endpoints need extra access granted on the key.
  4. Env var vs provider block: DD_API_KEY/DD_APP_KEY env vars work, but a provider block with stale values overrides them silently.

Fix: set the correct trio, prefer env vars from the secret manager in CI, and scope the app key to what Terraform manages.

Verify: the curl from step 2 returns 200, then terraform plan runs clean. Store the verification: a plan-only CI job catches the next rotation before apply time.

Evidence

The Terraform docs and API reference use the DD-API-KEY and DD-APPLICATION-KEY header pair with a per-site api_url; the provider needs all three correct. Verified against live docs 2026-09-26.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_ARQN2EzcFhTHmeVOCvMNvQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Diag: Terraform provider 401/403, validate the key pair and api_url <span>— Vectle</span></a>