Skip to content

sentry ​

For OpenTofu/Terraform on Sentry (the jianyuan/sentry provider). You log in once with sentry-cli (sentry-cli login), and cloudsesame hands that token to OpenTofu as SENTRY_AUTH_TOKEN. No .tfvars or .env file holding the token.

ts
sentry: { organization: "acme", scopes: ["project:write", "team:write", "alerts:write"] }
sh
cloudsesame sentry -- tofu plan    # or: eval "$(cloudsesame env sentry)", then tofu plan

The OpenTofu provider reads SENTRY_AUTH_TOKEN (and SENTRY_BASE_URL for self-hosted Sentry), never sentry-cli's login. That's the gap cloudsesame closes.

Options ​

FieldDefaultDescription
tokenEnv"SENTRY_AUTH_TOKEN"Environment variable with an auth token to use instead of the sentry-cli login, e.g. in CI. Passed on as SENTRY_AUTH_TOKEN.
urlsee self-hostedBase URL of a self-hosted Sentry, e.g. "https://sentry.acme.dev".
organizationOrganization slug the token must reach, e.g. "acme".
scopesScopes the token must have, e.g. ["project:write", "team:write"]. A higher level counts: project:admin covers project:write.

Checks ​

CheckRuns whenHowFix
loginSENTRY_AUTH_TOKEN isn't setThe token sentry-cli login saved in ~/.sentryclirc must work at GET /api/0/, which says who it belongs to and its scopes. It must be a personal token, not an organization token. With organization, it must also reach that organization. Otherwise mismatch.sentry-cli login, pasting a personal token
tokenSENTRY_AUTH_TOKEN (or tokenEnv) is set, e.g. in CIThe same checks, on that token.None: fix or unset the variable
scopesscopes is set and the token worksThe token's scopes, as /api/0/ reports them, must cover the list. Otherwise denied, e.g. sentry-cli's token lacks alerts:write.None (denied): a token's scopes can't change. Create a new one with them and run sentry-cli login again.

Which token ​

OpenTofu needs a personal token, and sentry-cli login steers you to the wrong kind: its browser link opens the organization tokens page, whose tokens (sntrys_…) only get the org:ci scope (releases and source maps). So when sentry-cli login asks to open the browser:

  1. Answer n.
  2. Open Personal Tokens (Settings → Account → Personal Tokens; <url>/settings/account/api/auth-tokens/ on self-hosted Sentry) and create a token with the scopes your resources need, for example Project, Team and Alerts at Admin or Read & Write, and Organization at Read.
  3. Paste it at sentry-cli's Enter your token prompt. It answers Valid token for user ….

Put the scopes your OpenTofu code needs in scopes. A token missing one then fails the scopes check instead of failing partway through tofu apply, and cloudsesame's messages (logged out, organization token, missing scopes) list them the way the token form does, e.g. Project: Read & Write, Alerts: Read & Write, Organization: Read. If sentry-cli login saved an organization token anyway, the login check is mismatch and offers to log in again.

In CI, an organization token in SENTRY_AUTH_TOKEN is accepted as is: scopes decides whether it's enough.

Personal tokens don't expire unless you revoke them, so unlike cloudflare the exported token keeps working.

Handing the token to OpenTofu ​

Two ways (see Shell integration):

  • cloudsesame sentry -- tofu plan (or a group: cloudsesame infra -- tofu plan) runs the command with SENTRY_AUTH_TOKEN set. Best for package.json scripts and agents.
  • eval "$(cloudsesame env)" exports SENTRY_AUTH_TOKEN into your shell; then run tofu as usual.

Self-hosted Sentry ​

The URL is, in order: url in the config, the URL inside an organization token, SENTRY_URL, [defaults] url in ~/.sentryclirc (what sentry-cli --url … login saves), else https://sentry.io. For anything but sentry.io, commands also get SENTRY_BASE_URL=<url>/api/, the form the OpenTofu provider expects, and the login fix becomes sentry-cli --url <url> login.

Running sentry-cli ​

You don't need to install it. cloudsesame only runs it to log in: it uses sentry-cli if it's on your PATH, else runs it with Bun (bun x @sentry/cli login), like cf. Only when neither exists is the line missing, with Bun's installer as the fix. Checking the token is a direct HTTPS call.

CI ​

Set SENTRY_AUTH_TOKEN to a token (an internal integration token suits CI). It's verified instead of the sentry-cli login and passed through unchanged. With tokenEnv: "SENTRY_TF_TOKEN", the token is read from that variable and passed on as SENTRY_AUTH_TOKEN.

Quirks ​

  • Only ~/.sentryclirc is read: not a project-level .sentryclirc, sentrycli.ini in the config directory, or SENTRY_PROPERTIES. Set url or SENTRY_AUTH_TOKEN if you keep the login elsewhere.
  • Organization-level access is checked by reading the organization. Write access can't be tested without changing something, so declare scopes.
  • With no config, sentry isn't checked unless you name it (cloudsesame sentry): sentry-cli is common in app repos for source maps, so having it installed doesn't mean the repo needs a login.
  • Bun and the standalone binaries honor HTTPS_PROXY; Node's built-in fetch does not (unless NODE_USE_ENV_PROXY=1 on Node 24+).