Set up the CI plan upload
Run terraform plan in your own CI with your credentials, send the plan to CloudBooster Guard, and fail the job when a finding gates the change.
Set up the CI plan upload
The CI plan upload runs terraform plan in your CI, with your credentials and your backend,
and sends the plan to CloudBooster Guard. Guard resolves it against your connected cloud accounts,
records the verdicts, posts the cbxguard/ci-plan check on the merge request or pull request
(by default also cbxguard/review, with the same result), and fails the job when a finding gates
the change.
Use it for the Terraform roots the server-side review cannot plan offline.
A remote backend is not one of them: the review swaps it for an empty local backend and never
reads your state. The roots that still need this upload are those with data sources that call the
cloud or the network (including terraform_remote_state), an override file that sorts after
zz_cbx_backend_override.tf and declares its own backend, private modules the review cannot
fetch, kubernetes_manifest, or a remote Helm chart. See
Known limits. Everything on this page is
self-serve. You download the templates and the cloudguard binary from a public registry, with
no token from CloudBooster.
Plan. The upload authenticates with an API token, so it needs the Pro plan or above.
Before you start:
- a cloud account connected under Cloud accounts in the Console (see Connect an AWS account);
- the repository watched under Repositories (a merge request or pull request of a repository
you do not watch is refused with
repo_not_watched); - a CI job that can run
terraform planfor the root, with the cloud credentials that plan needs.
1. Create an API token
- In the Console, open Settings → API tokens, or select Create token on the CI plan-ingest card under Integrations.
- Name the token after the pipeline and pick the preset CI pipeline.
- Pick an expiry (90 days is a good default) and copy the secret. It is shown once only.
2a. GitLab CI
Copy the template into your repository. The commands below use v0.7.0, the current release
(see Which release). No token is needed:
Include it in .gitlab-ci.yml:
The stage: line must name a stage your pipeline declares. Without one, the job runs in test,
and a pipeline with no test stage fails with chosen stage does not exist.
Add the variables under Settings → CI/CD → Variables:
| Variable | Value |
|---|---|
CBX_GUARD_TOKEN | The token from step 1. Masked. Leave Protected off: merge-request pipelines run on unprotected branches. |
CBX_GUARD_API_URL | Your Guard API, the origin of the Console, e.g. https://guard.example.com. |
Add the cloud credentials the plan needs in the job's before_script or as CI/CD variables, as
for any plan job. The job runs on merge-request pipelines only.
2b. GitHub Actions
Copy the action and the example workflow into your repository. The commands below use v0.7.0,
the current release (see Which release). No token is needed:
The two files are also at these URLs:
https://gitlab.com/api/v4/projects/cloudbooster.io%2Fplatform%2Fcbx-guard/packages/generic/cloudguard/v0.7.0/cbx-guard-action.ymlhttps://gitlab.com/api/v4/projects/cloudbooster.io%2Fplatform%2Fcbx-guard/packages/generic/cloudguard/v0.7.0/cbx-guard-workflow.yml
Edit .github/workflows/cbx-guard.yml: set TF_ROOT, account and version (the release
you copied), and add your cloud credentials before the plan step.
Add the settings under Settings → Secrets and variables → Actions: the secret
CBX_GUARD_TOKEN (the token from step 1) and the variable CBX_GUARD_API_URL.
Which release
This guide names v0.7.0, the current cloudguard release. Pin it in CBX_GUARD_VERSION (or the
action's version input) and keep it there until you choose to move. To move to a newer release,
check that the release exists and then replace v0.7.0 in the template URL, in
CBX_GUARD_VERSION and in version. Every release publishes its checksum file at one address, with
no token:
Replace <version> with a tag such as v0.7.0. The address answers with the checksum file when the
release exists and with an error when it does not. Every release file sits next to it under the
same <version>.
The registry has no public index and the project's Releases and Packages pages need a sign-in (checked 2026-11-17), so no listing answers without a token. The checksum address is the page that does.
3. Check it works
Open a merge request or pull request that changes the root. The job:
- downloads the
cloudguardbinary of the release you pinned and verifies its SHA-256; - runs
terraform planand sends the plan to Guard; - prints the verdict and fails when a finding gates the change.
The merge request or pull request gets the cbxguard/ci-plan check and, by default,
cbxguard/review with the same result. Exit code 2 means a set-up
problem, and the job log names it in one line: a missing variable, a bad token, an account that
is not connected, or a repository you do not watch.
Contributions from forks
On GitLab, a merge request from a fork is gated by this job, run in your project. Guard never posts on the fork, and nobody has to give Guard access to a contributor's fork.
GitLab reads a fork merge request's pipelines from the fork, so a status Guard posts in your
project doesn't reach the merge request. A merge request pipeline that runs in your project
does: GitLab's Run pipelines in the parent project for merge requests from forks. The
cbx-guard job in that pipeline uploads the plan and fails when a finding gates the change, and
Guard posts cbxguard/ci-plan (and, by default, cbxguard/review) on the same pipeline.
What your project configures
- The job, as in 2a. GitLab CI, in your project's own
.gitlab-ci.yml. The template already runs it on merge request pipelines (merge_request_event), including those for merge requests from forks. - Your CI configuration, not the fork's. By default, a pipeline your project runs for a fork's
merge request reads
.gitlab-ci.ymlfrom the fork's branch, which the fork's owner can change, for example to drop thecbx-guardjob. Under Settings → CI/CD → General pipelines → CI/CD configuration file, enter.gitlab-ci.yml@<group>/<project>:<default branch>, for example.gitlab-ci.yml@acme/infra:main. Every pipeline in the project then runs the configuration on your default branch, including the files it includes withinclude: local:. A change to your CI configuration takes effect once it merges. - The variables
CBX_GUARD_TOKENandCBX_GUARD_API_URLas in 2a. Leave Protected off: a fork's merge request pipeline runs on an unprotected ref. - Pipelines must succeed on, under Settings → Merge requests, so the job's result holds the merge.
For each merge request from a fork
- Read the change first. The pipeline runs the fork's Terraform in your project, with your
project's CI/CD variables:
CBX_GUARD_TOKENand your cloud credentials. Terraform can run code while it plans, for example through anexternaldata source or a provider. GitLab shows a warning to the same effect before the pipeline runs. - Run the pipeline in your project: on the merge request, open Pipelines and select Run pipeline. It takes a member of your project who can run pipelines, at least a Developer.
- Run it again after every push to the fork. A new commit has no pipeline in your project until someone runs one.
What the merge request shows
| When | The widget | With Pipelines must succeed on |
|---|---|---|
| No pipeline in your project yet | No Guard check. Guard's note on the merge request says it is gated through your CI's plan upload, and links here. | The merge request can't merge while it has no pipeline. A pipeline the fork runs on its own counts instead. |
| Your project's pipeline ran, and a finding gates the change | The pipeline in your project, failed: the cbx-guard job and cbxguard/ci-plan failed | Merge blocked |
| Your project's pipeline ran, and nothing gates | The pipeline in your project, passed | Merges |
| The fork pushed a new commit since | The earlier pipeline, on the earlier commit | Can't merge until a pipeline runs on the new commit |
The pipeline lives in your project, so everyone who can read your project sees it, whether or not they can read the fork.
Before you merge, check that the merge request's latest pipeline is the one in your project. A pipeline the fork's owner runs in the fork later, on the same commit, becomes the merge request's latest pipeline, and Pipelines must succeed then reads that one.
On GitHub, a workflow for a pull request from a fork gets no secrets, so the job stops with exit code 2 before it uploads anything (see Troubleshooting).
Variables
The GitLab template and the GitHub action use one set of names. The action takes them as inputs
(account, version, fail-on, …).
| Variable | Required | Meaning |
|---|---|---|
CBX_GUARD_API_URL | yes | The Guard API base URL (https://). |
CBX_GUARD_TOKEN | yes | The API token. A masked variable or secret only. |
CBX_GUARD_ACCOUNT | yes | The cloud account the plan targets, connected to the token's organisation. |
CBX_GUARD_VERSION | yes | The cloudguard release, e.g. v0.7.0. |
TF_ROOT | no | The Terraform root (GitLab). Default .. |
CBX_GUARD_FAIL_ON | no | Fail on this tier or worse instead of the repository's gate: critical, high, watch or clean. |
CBX_GUARD_PLAN | no | A plan JSON an earlier job wrote; the job then skips Terraform (GitLab). |
CBX_GUARD_SHA256 | no | Pin the binary's checksum, from the release's SHA256SUMS. |
CBX_GUARD_ARGS | no | Extra cloudguard flags. |
CBX_GUARD_TERRAFORM_VERSION | no | The Terraform the job downloads when the image has none (GitLab). Default 1.9.8. A terraform already on PATH is used instead. |
CBX_GUARD_DOWNLOAD_URL | no | The package registry to download the binary from. Set it only for a private mirror of the public registry. |
CBX_GUARD_DOWNLOAD_TOKEN | no | A token for that private mirror, sent as PRIVATE-TOKEN. Not needed for the public registry. |
The gate threshold
The job and the cbxguard/ci-plan check that its upload posts to the pull request (and
cbxguard/review, which by default carries the same result) do not always give the same answer:
- The job fails on the threshold below, whether or not the repository's gate is armed.
- The posted check blocks only while the repository's gate is armed, and then on the tiers the gate blocks. While the gate is disarmed, the check reads Advisory: … (gate not armed) and never blocks a merge.
So on a disarmed gate a critical verdict fails the job while the check stays advisory, and a
CBX_GUARD_FAIL_ON / fail-on that differs from the gate's tiers changes the job only. Guard
picks the job's threshold in this order:
CBX_GUARD_FAIL_ON/fail-on, when set. A verdict at that tier or worse fails the job, whatever the repository's gate says. Leave it unset unless you mean the job to be stricter or looser than the repository's gate.- The repository's gate. On a merge request or pull request of a watched repository, the job fails on the tiers the repository's gate blocks (see Choose what blocks).
critical. The default, as for the check. An upload outside a merge request or pull request uses it too.
The job's log names the threshold that applied, for example
gate threshold: blocks critical (the repository's gate).
On GitLab, a repository set to grey posts cbxguard/review as skipped when Guard couldn't
review a change. With Pipelines must succeed on, GitLab lets that merge request merge only when
Skipped pipelines are considered successful is on too, unless other jobs in its pipeline pass
(see GitLab: a review that couldn't run).
Exit codes
| Code | Meaning | Job |
|---|---|---|
| 0 | Ran; nothing gates at the threshold. | Passes. |
| 1 | Ran; a finding gates the change. A checksum mismatch also exits 1. | Fails. |
| 2 | Set-up, transport, auth or server error: a missing variable, no token, an unreachable API, a timeout, HTTP 401 (bad token), 403 (no ingest scope, or account_not_in_org), 413 (plan over 10 MiB), 422 (repo_not_watched, or an invalid request), 503 (upload_contended, safe to retry). | Fails. |
To report without blocking while you roll out, let exit code 1 pass and keep 2 failing:
On GitHub, set continue-on-error: true on the step. It also lets exit code 2 pass.
Troubleshooting
| You see | Why | Fix |
|---|---|---|
GitLab: cbx-guard job: chosen stage does not exist, and no pipeline starts | The template puts the job in test, and your stages: list has no test | Set stage: on cbx-guard to one of your stages, or add test to stages:. |
HTTP 422 repo_not_watched | The token's organisation does not watch the repository on that forge | Watch it in the Console under Repositories. |
HTTP 403 account_not_in_org | CBX_GUARD_ACCOUNT is not a cloud account connected to the token's organisation | Connect it under Cloud accounts, or set the account that is connected. |
HTTP 503 upload_contended | Another upload for the same pull request kept colliding with this one. Nothing from this upload was recorded or posted | Re-run the job. A 503 is safe to retry, and parallel jobs for several roots of one pull request are supported. |
HTTP 401 | The token is wrong, expired or revoked | Create a new token (step 1) and update CBX_GUARD_TOKEN. See API tokens. |
| The job exits 2 on a pull request from a fork (GitHub) | GitHub gives no secrets to a pull_request workflow from a fork | Expected. Review the change, then run the plan from a branch in your repository. |
| GitLab: a merge request from a fork shows no Guard check | Its pipeline ran in the fork, or none ran yet | Run its pipeline in your project, as Contributions from forks says. |
Upgrading
Each release publishes the binaries, SHA256SUMS and the templates together. To upgrade, copy the
templates again from the new release's URL and set CBX_GUARD_VERSION (or version) to it in the
same commit.