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.
sentry: { organization: "acme", scopes: ["project:write", "team:write", "alerts:write"] }cloudsesame sentry -- tofu plan # or: eval "$(cloudsesame env sentry)", then tofu planThe 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
| Field | Default | Description |
|---|---|---|
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. |
url | see self-hosted | Base URL of a self-hosted Sentry, e.g. "https://sentry.acme.dev". |
organization | Organization slug the token must reach, e.g. "acme". | |
scopes | Scopes the token must have, e.g. ["project:write", "team:write"]. A higher level counts: project:admin covers project:write. |
Checks
| Check | Runs when | How | Fix |
|---|---|---|---|
| login | SENTRY_AUTH_TOKEN isn't set | The 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 |
| token | SENTRY_AUTH_TOKEN (or tokenEnv) is set, e.g. in CI | The same checks, on that token. | None: fix or unset the variable |
| scopes | scopes is set and the token works | The 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:
- Answer n.
- 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. - 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 withSENTRY_AUTH_TOKENset. Best forpackage.jsonscripts and agents.eval "$(cloudsesame env)"exportsSENTRY_AUTH_TOKENinto your shell; then runtofuas 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
~/.sentryclircis read: not a project-level.sentryclirc,sentrycli.iniin the config directory, orSENTRY_PROPERTIES. SeturlorSENTRY_AUTH_TOKENif 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,
sentryisn'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-infetchdoes not (unlessNODE_USE_ENV_PROXY=1on Node 24+).
