Skip to content

Recipes ​

Configs for common setups. Copy one, change the names, and run cloudsesame check to see where you stand.

Web app on Google Cloud ​

Your app talks to Google APIs through the client libraries, which use Application Default Credentials (ADC). Check them before dev starts:

ts
import type { Config } from "cloudsesame";

export default {
  gcloud: { credentials: "adc", project: "acme-dev" },
} satisfies Config;
json
{
  "scripts": {
    "predev": "cloudsesame predev",
    "dev": "vite"
  }
}

credentials is "adc" for code that uses Google SDKs or OpenTofu/Terraform, "user" for scripts that call the gcloud CLI, and "both" (the default) when you're not sure. project catches a CLI pointed at the wrong project, and offers gcloud config set project acme-dev.

predev is lenient: offline, it asks whether to continue; if you skip a login, dev still starts.

Infra repo: OpenTofu on GCP and AWS ​

OpenTofu/Terraform needs gcloud ADC and AWS credentials, for the right accounts. A plan that starts with expired credentials fails halfway, so check first:

ts
import type { Config } from "cloudsesame";

export default {
  gcloud: {
    credentials: "both",
    account: "me@acme.dev",
    project: "acme-prod",
    quotaProject: "acme-billing", // project billed when SDKs call Google APIs as you
  },
  aws: [
    { profile: "staging", accountId: "111111111111" },
    { profile: "prod", accountId: "222222222222" },
  ],
  groups: { infra: ["gcloud", "aws"] },
} satisfies Config;
json
{
  "scripts": {
    "auth": "cloudsesame infra",
    "plan": "cloudsesame infra && tofu plan",
    "apply": "cloudsesame infra && tofu apply"
  }
}

cloudsesame infra checks both clouds. A login to the wrong account or project counts as not ready, and cloudsesame offers the command that fixes it:

  • gcloud logged out: gcloud auth login me@acme.dev --update-adc (one login for both CLI and ADC).
  • Wrong quota project: gcloud auth application-default set-quota-project acme-billing.
  • AWS SSO session expired: aws sso login --profile prod.

Not using package.json? Run cloudsesame infra && tofu plan from a Makefile, a justfile or your shell.

Cloudflare Workers ​

wrangler deploy uses your wrangler login. Check it before dev and deploys:

ts
import type { Config } from "cloudsesame";

export default {
  wrangler: { account: "Acme" }, // ID or name, like account_id in wrangler.jsonc
} satisfies Config;
json
{
  "scripts": {
    "predev": "cloudsesame predev",
    "deploy": "cloudsesame wrangler && wrangler deploy"
  }
}

Logged out or expired, cloudsesame offers wrangler login. In CI, set CLOUDFLARE_API_TOKEN instead: wrangler uses it, and so does the check.

DNS on Cloudflare with OpenTofu ​

The Cloudflare provider only reads a token from CLOUDFLARE_API_TOKEN. Run OpenTofu through cloudsesame and it gets one from your cf login, refreshed every run:

ts
import type { Config } from "cloudsesame";

export default {
  gcloud: { credentials: "adc", project: "acme-prod" }, // state bucket, say
  cloudflare: { zones: ["acme.dev", "acme.io"] },
  groups: { infra: ["gcloud", "cloudflare"] },
} satisfies Config;
json
{
  "scripts": {
    "plan": "cloudsesame infra -- tofu plan",
    "apply": "cloudsesame infra -- tofu apply"
  }
}

The first time, cloudsesame offers cf auth login (a browser login; cf runs through Bun, so there's nothing to install). After that, every plan and apply refreshes the login silently and runs tofu with CLOUDFLARE_API_TOKEN set:

✔ gcloud adc
✔ cloudflare login  me@acme.dev
✔ cloudflare zones  acme.dev, acme.io

Prefer typing tofu plan yourself? Set the token in your shell with eval "$(cloudsesame env infra)", then run tofu directly (rerun it when the token expires, after about an hour). See Shell integration.

wrangler login doesn't cover this: OpenTofu doesn't read it, and it has no DNS access (see Providers). If the repo also deploys Workers, check both: groups: { infra: ["wrangler", "cloudflare"] }.

In CI, set CLOUDFLARE_API_TOKEN to an API token (the Edit zone DNS template): cloudsesame verifies it instead of the cf login and passes it through.

Sentry with OpenTofu ​

The Sentry provider reads its token from SENTRY_AUTH_TOKEN, not from sentry-cli login. Run OpenTofu through cloudsesame and it gets the token from your login:

ts
import type { Config } from "cloudsesame";

export default {
  sentry: { organization: "acme", scopes: ["project:write", "team:write", "alerts:write"] },
  groups: { infra: ["sentry"] }, // add your state backend's provider, e.g. gcloud
} satisfies Config;
json
{
  "scripts": {
    "plan": "cloudsesame infra -- tofu plan",
    "apply": "cloudsesame infra -- tofu apply"
  }
}

The first time, cloudsesame offers sentry-cli login (run through Bun if it isn't installed): answer n when it offers to open the browser (it links to organization tokens, which can't manage projects), create a personal token with the scopes above, and paste it. After that, every plan and apply runs tofu with SENTRY_AUTH_TOKEN set:

✔ sentry login  me@acme.dev
✔ sentry scopes  project:write, team:write, alerts:write

Prefer typing tofu plan yourself? Run eval "$(cloudsesame env infra)" once per shell. Self-hosted Sentry: add url: "https://sentry.acme.dev", and commands get SENTRY_BASE_URL too. In CI, set SENTRY_AUTH_TOKEN: it's verified instead of the login and passed through. See sentry.

Azure ​

Pin the tenant and the subscription (by ID or name):

ts
import type { Config } from "cloudsesame";

export default {
  az: { tenant: "00000000-0000-0000-0000-000000000000", subscription: "Contoso Dev" },
} satisfies Config;

Logged out or in the wrong tenant, cloudsesame offers az login --tenant 00000000-0000-0000-0000-000000000000. In the wrong subscription, it offers az account set --subscription "Contoso Dev".

One subscription at a time

az has a single active subscription, so list one subscription per config. For several environments, keep a config file per environment and pick it with --config, e.g. cloudsesame -c sesame.prod.json.

AI APIs: Vertex AI and Azure OpenAI ​

A valid login isn't enough to call a model: you also need the role. List the permissions the code uses, and a missing one shows up before the first request fails:

ts
import type { Config } from "cloudsesame";

export default {
  gcloud: {
    credentials: "adc",
    project: "acme-ai",
    permissions: [
      "aiplatform.endpoints.predict", // Vertex AI / Gemini generateContent
      "speech.recognizers.recognize", // Speech-to-Text v2
    ],
  },
} satisfies Config;
ts
import type { Config } from "cloudsesame";

export default {
  az: {
    subscription: "Contoso AI",
    dataActions: ["Microsoft.CognitiveServices/accounts/OpenAI/deployments/chat/completions/action"],
    permissionScope:
      "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ai/providers/Microsoft.CognitiveServices/accounts/contoso-openai",
  },
} satisfies Config;
✔ gcloud adc
✖ gcloud permissions  acme-ai: missing speech.recognizers.recognize

There's nothing to run for a missing permission, so cloudsesame offers Skip or Stop and exits with code 4 if it stays missing. It checks IAM only: an API that isn't enabled, or a model you have no quota for, still fails at call time. See Permissions for the details.

Monorepo ​

cloudsesame uses the nearest config, looking from the current directory up to the git root. Package scripts run in the package's directory, so each package can have its own:

acme/
├─ sesame.config.ts            ← fallback for the rest of the repo
├─ apps/web/sesame.config.ts   ← gcloud ADC only
└─ infra/sesame.config.ts      ← gcloud and aws

Configs don't merge: the nearest one wins.

Or keep one config at the root and give each package a group:

ts
import type { Config } from "cloudsesame";

export default {
  gcloud: { credentials: "both", project: "acme-dev" },
  aws: { profile: "dev" },
  groups: {
    web: ["gcloud"],
    infra: ["gcloud", "aws"],
  },
} satisfies Config;
json
{
  "scripts": {
    "predev": "cloudsesame predev web"
  }
}
json
{
  "scripts": {
    "plan": "cloudsesame infra && tofu plan"
  }
}

A group lists providers, so it includes every target of those providers: with two AWS profiles, infra checks both.

Never block anyone ​

For a team that wants the reminder but never a blocked script: warn about missing logins, continue offline, and skip the animation.

ts
import type { Config } from "cloudsesame";

export default {
  gcloud: { credentials: "adc" },
  offline: "continue", // predev: don't ask when offline
  unauthenticated: "skip", // warn about missing logins, never prompt
  animation: "never",
} satisfies Config;

Anyone can still log in with cloudsesame --unauthenticated prompt, since flags override the config.

CI pipelines ​

Scripts like predev also run in CI, where there's no terminal to prompt in. By default, anything that would prompt fails with exit code 4 and prints the command to run. Choose what fits the job:

The jobUse
Needs the cloudThe default. It fails fast with the fix, before a long job starts.
Doesn't need the cloud (lint, unit tests)--skip on that run, or noTerminal: "skip" in the config to skip everywhere.
Must have everything, skips included--strict: skipped providers count as failures.

To gate a job on credentials it set up earlier, run check. It never prompts and exits 4 if anything isn't ready:

yaml
# .github/workflows/deploy.yml
- run: npx cloudsesame check infra

The runner uses the same config as developers, so the profiles, accounts and projects it names must exist there too.

To read the status from a script, use --json:

sh
cloudsesame check --json | jq -r '.results[] | select(.state != "ok") | "\(.provider) \(.label): \(.message)"'

See CI and AI agents for the JSON fields and the Agent Skill.