Pre-Requisites
Pre-Requisites
Complete these first:
- Deploy Application at least once locally
- A CI deploy token (minted in the web app under Settings → CI/CD Tokens), or AWS credentials configured for your CI environment
Introduction
The Fjall CLI runs in CI/CD pipelines without extra configuration. When it detects a non-interactive environment (no TTY), it switches to plain text output and returns standard exit codes. Official plugins cover GitHub Actions and Buildkite. For any other CI system, install and invoke the CLI directly. Pipelines authenticate with a CI deploy token. The token doubles as the pipeline’s AWS credential: the CLI exchanges it for short-lived, deploy-scoped AWS credentials in your connected account, so you never store AWS keys in CI.CI Deploy Tokens
Fjall issues three kinds of token. Only one belongs in a pipeline:Scopes and Opt-In Grants
Every CI deploy token carries a fixed, least-privilege base scope set:read, deploy, and deploy:oidc:mint. That is enough to run deploys and mint short-lived AWS sessions, and nothing more. It cannot manage team members, tokens, or organisation settings. The base set is stamped at creation and cannot be widened afterwards.
Two further grants are opt-in at mint time. Tick them in the mint dialog if your pipeline needs them:
A token minted without the grant fails the run with a scope denial. Grants cannot be added to an existing token, so mint a replacement and swap the CI secret.
Deploy tokens expire within 90 days. The cap is enforced by the web-app mint form and by the API, which rejects a longer expiry regardless of client. Rotate before expiry by minting a replacement and updating your CI secret.
Minting and Managing Tokens
Minting a deploy token is admin-equivalent (it grants the org-wide AWS deploy path), so it requires an interactive browser session. An owner or admin mints it in the web app under Settings → CI/CD Tokens, optionally restricted to one application, environment, or connected account. The token is shown once, so store it as a CI secret immediately. API-key-authenticated callers, including the CLI, cannot mint deploy tokens, so the CLI has noci token create command. fjall ci setup writes the workflow file and prints the web-app URL to mint at; the constraints and the expiry are chosen in that dialog.
Everything after the mint works from the CLI:
FJALL_API_KEY in your CI provider’s secrets.
Workflow Setup
fjall ci setup detects the provider, repository, and application, resolves a deployment target, checks that the target’s AWS account is connected to your organisation, and writes the plugin-form workflow file. It then prints the web-app URL where the deploy token is minted and the secret name to store it under. With --plan it prints the complete workflow file it would write and writes nothing:
fjall ci verify dry-runs the auth handshake (credential, principal kind, expiry runway, and application access) before your first pipeline run. Exit 0 means ready, exit 1 means at least one check failed.
fjall ci setup never holds a deploy token: the API only permits minting
from a signed-in browser session. The command writes the workflow file and
stops; mint the token in the web app (Settings → CI/CD Tokens) and store
it as the CI secret it names, then run fjall ci verify.Choosing the Deployment Target
Two separate inputs answer two separate questions. Getting them confused is the most common CI failure:fjall ci run never falls back to the active target set by fjall target set. That fallback is deliberately absent so a committed activeTarget or an unrelated laptop can never re-aim a pipeline. Pass deploy-target (or environment) on every CI step, or the run fails closed and lists the organisation’s targets.
environment is the alternative selector. It resolves the single connected account on that stage, and fails when the stage matches zero or several accounts. On a deploy it additionally chooses the .env.<stage> Docker build-arg tier. region re-qualifies the region within the resolved target’s account.
Tier targets accept neither deploy-target nor environment. Organisation infrastructure always deploys to the management account, so the plugins’ tier path accepts only force, verbose, and no-cascade (organisation only) and rejects every other input rather than dropping it.
GitHub Actions
Thefjall-tech/fjall-deploy-action is a composite action that installs the CLI and runs it with the right flags.
Minimal Workflow (Recommended)
A CI deploy token is the only secret you need. The CLI exchanges it for short-lived AWS credentials scoped to the deploy, and the run is recorded in your Fjall dashboard:FJALL_API_KEY repository secret. Your AWS account must already be connected to Fjall.
With AWS OIDC
If you prefer AWS-native credential management, use GitHub’s OIDC provider to assume an IAM role. There are no long-lived secrets to rotate:With Static AWS Credentials
Store AWS keys as repository secrets. Simplest to set up, but the keys are long-lived and need rotation:Split Infrastructure and Code Deploys
Run infrastructure changes and code deploys as separate jobs for faster iteration:Action Inputs
The action is a thin shim ontofjall ci run for application targets, and onto fjall org|platform|account deploy for tier targets. Every input maps 1:1 to a CLI flag, and the CLI owns command and flag validation.
Action Outputs
A
plan run with pending changes exits 2 (surfaced as result: plan-pending), so a plan, approve, apply pipeline can branch on it without treating it as a failure.
cli-version defaults to 39, the CLI major this plugin release is built
for, and the same major as current @fjall/components-infrastructure
releases. Set it to auto to derive the major from your application’s constructs pin
instead, or to an exact version you have validated locally (fjall --version).
Avoid latest: it floats across releases, and if it drifts behind your
application’s constructs the deploy is refused by the engine compatibility
check. Compatibility is a floor rather than
a match (the engine major must be at least the constructs major, and nothing
caps a newer one), so auto resolves to the lowest major that satisfies your
pin: always compatible, but engine work released in a later major stays out of
reach until you bump the constructs pin. An exact, validated major is the
better default for a team that upgrades deliberately.Buildkite
Thefjall-tech/fjall-deploy-buildkite-plugin installs the CLI and runs it with the right flags.
Minimal Pipeline
FJALL_API_KEY through your Buildkite secrets storage. On clustered or Buildkite-hosted agents, add a cluster secret named FJALL_API_KEY (Agents → your cluster → Secrets) and the plugin fetches it when the env var is absent. On self-hosted agents without cluster secrets, export it from an agent environment hook.
The same tracking caveat applies as on GitHub Actions: without FJALL_API_KEY, deploys run but are invisible to Fjall. The cli-version guidance above applies here too.
With AWS OIDC
Staging to Production Pipeline
Plugin Properties
The plugin accepts the same surface as the GitHub action.build-args and build-secrets are YAML arrays of strings rather than newline-separated blocks:
The plugin records
fjall-deploy:result, fjall-deploy:duration, and any fjall-deploy:approval-token as build meta-data (buildkite-agent meta-data get fjall-deploy:result), and a plan-pending run adds a warning annotation to the build.
Raw CLI Usage (Any CI System)
If you use a different CI system (GitLab CI, CircleCI, Jenkins), install and invoke the CLI directly.Setup
fjall ci run <deploy|destroy|build> <target> is the single CI entry point, and the same command both official plugins invoke for application targets. It forces non-interactive output, skips confirmation prompts, and rejects flags that do not apply to the command you are running (for example, deploy-only flags on a destroy).
Key Flags
--no-cascade is not a fjall ci run flag. It exists only on the organisation tier leaf: fjall org deploy --no-cascade.
Invoking fjall deploy api --target production-use1 --non-interactive --skip-confirmation directly still works. fjall ci run wraps the same engine with CI-safe defaults.
Exit Codes
Exit
4 means the deploy stopped at the destruction gate. It is a decision, not a failure, and the cure depends on the outcome printed with the ticket. When consent was withheld, surface the printed ticket to a human and re-run with the named consents once reviewed, bound with --destruction-consent-digest.
The ticket ends with a ticket digest: line, printed by a --plan run and by the withheld run itself, so the digest to bind against is already in the job log.
A consented pin has already written the config change: commit it and re-run without re-supplying the consent. A declined, invalid, or not-yet-executable consent prints what to change. Always follow the printed cure.
Reading the Output
From fjall 38, the CLI splits its two streams by what a line is, not by which command wrote it.
Never scrape progress off stdout. A failed command leaves stdout empty, so branch on the exit code and never on whether stdout had content.
The one exception is a machine protocol the caller asked for, where a failure can arrive as a self-describing document on stdout. On
fjall ci run, and on every other fjall ci command, that protocol is --agent. Elsewhere in the CLI, --mcp-protocol and a --json / --output json document do the same job on the commands that carry them.
A failure written as prose is never on stdout.
A successful deploy of an application with a website URL prints that URL on stdout, so a pipeline can capture it:
Environment Variables
Example: GitLab CI
Example: CircleCI
FJALL_API_KEY as a project secret in either system.
Setting Up AWS Credentials
Whichever CI system you use, the Fjall CLI needs AWS credentials to deploy. Here are the common approaches, from most to least recommended:Fjall Deploy Token (Recommended)
SetFJALL_API_KEY to a CI deploy token and skip AWS credential setup entirely. The CLI exchanges the token for short-lived, deploy-scoped AWS credentials in your connected account, and every run is tracked in your dashboard.
AWS OIDC Federation
Most CI systems support OIDC federation with AWS. This avoids storing long-lived secrets:- Create an IAM OIDC identity provider for your CI system
- Create an IAM role with a trust policy scoped to your repo or pipeline
- Use your CI’s OIDC integration to assume that role
Static Credentials
StoreAWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as CI secrets. Simpler to set up but requires key rotation.
Instance Profiles
When your CI agents run on EC2 (for example, self-hosted Buildkite agents), attach an IAM instance profile with the required permissions. No credential management needed.Next Steps
Deploy an Application
Run a full deploy locally before wiring it into CI/CD.
ci Command Reference
Every
fjall ci subcommand, token verb, and flag.Deployment Targets
How Fjall derives AWS profiles and names deployment targets.
Destructive Changes
Handle exit code 4 and the consent ceremony in a pipeline.