CloudBoosterDocs

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 plan for the root, with the cloud credentials that plan needs.

1. Create an API token

  1. In the Console, open Settings → API tokens, or select Create token on the CI plan-ingest card under Integrations.
  2. Name the token after the pipeline and pick the preset CI pipeline.
  3. 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:

curl -fsSL --create-dirs -o .gitlab/ci/cbx-guard.gitlab-ci.yml \
  https://gitlab.com/api/v4/projects/cloudbooster.io%2Fplatform%2Fcbx-guard/packages/generic/cloudguard/v0.7.0/cbx-guard.gitlab-ci.yml
git add .gitlab/ci/cbx-guard.gitlab-ci.yml

Include it in .gitlab-ci.yml:

include:
  - local: .gitlab/ci/cbx-guard.gitlab-ci.yml # copied from release v0.7.0
 
cbx-guard:
  stage: test # use one of your stages
  variables:
    CBX_GUARD_VERSION: v0.7.0 # the release you copied the template from
    CBX_GUARD_ACCOUNT: "111122223333" # the cloud account the plan targets
    TF_ROOT: infra/prod # the Terraform root, relative to the repository

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:

VariableValue
CBX_GUARD_TOKENThe token from step 1. Masked. Leave Protected off: merge-request pipelines run on unprotected branches.
CBX_GUARD_API_URLYour 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:

base=https://gitlab.com/api/v4/projects/cloudbooster.io%2Fplatform%2Fcbx-guard/packages/generic/cloudguard/v0.7.0
curl -fsSL --create-dirs -o .github/actions/cbx-guard/action.yml "$base/cbx-guard-action.yml"
curl -fsSL --create-dirs -o .github/workflows/cbx-guard.yml "$base/cbx-guard-workflow.yml"

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.yml
  • https://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:

https://gitlab.com/api/v4/projects/cloudbooster.io%2Fplatform%2Fcbx-guard/packages/generic/cloudguard/<version>/SHA256SUMS

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:

  1. downloads the cloudguard binary of the release you pinned and verifies its SHA-256;
  2. runs terraform plan and sends the plan to Guard;
  3. 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

  1. 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.
  2. Your CI configuration, not the fork's. By default, a pipeline your project runs for a fork's merge request reads .gitlab-ci.yml from the fork's branch, which the fork's owner can change, for example to drop the cbx-guard job. 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 with include: local:. A change to your CI configuration takes effect once it merges.
  3. The variables CBX_GUARD_TOKEN and CBX_GUARD_API_URL as in 2a. Leave Protected off: a fork's merge request pipeline runs on an unprotected ref.
  4. Pipelines must succeed on, under Settings → Merge requests, so the job's result holds the merge.

For each merge request from a fork

  1. Read the change first. The pipeline runs the fork's Terraform in your project, with your project's CI/CD variables: CBX_GUARD_TOKEN and your cloud credentials. Terraform can run code while it plans, for example through an external data source or a provider. GitLab shows a warning to the same effect before the pipeline runs.
  2. 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.
  3. 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

WhenThe widgetWith Pipelines must succeed on
No pipeline in your project yetNo 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 changeThe pipeline in your project, failed: the cbx-guard job and cbxguard/ci-plan failedMerge blocked
Your project's pipeline ran, and nothing gatesThe pipeline in your project, passedMerges
The fork pushed a new commit sinceThe earlier pipeline, on the earlier commitCan'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, …).

VariableRequiredMeaning
CBX_GUARD_API_URLyesThe Guard API base URL (https://).
CBX_GUARD_TOKENyesThe API token. A masked variable or secret only.
CBX_GUARD_ACCOUNTyesThe cloud account the plan targets, connected to the token's organisation.
CBX_GUARD_VERSIONyesThe cloudguard release, e.g. v0.7.0.
TF_ROOTnoThe Terraform root (GitLab). Default ..
CBX_GUARD_FAIL_ONnoFail on this tier or worse instead of the repository's gate: critical, high, watch or clean.
CBX_GUARD_PLANnoA plan JSON an earlier job wrote; the job then skips Terraform (GitLab).
CBX_GUARD_SHA256noPin the binary's checksum, from the release's SHA256SUMS.
CBX_GUARD_ARGSnoExtra cloudguard flags.
CBX_GUARD_TERRAFORM_VERSIONnoThe 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_URLnoThe package registry to download the binary from. Set it only for a private mirror of the public registry.
CBX_GUARD_DOWNLOAD_TOKENnoA 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:

  1. 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.
  2. 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).
  3. 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

CodeMeaningJob
0Ran; nothing gates at the threshold.Passes.
1Ran; a finding gates the change. A checksum mismatch also exits 1.Fails.
2Set-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:

cbx-guard: # GitLab
  allow_failure:
    exit_codes: [1]

On GitHub, set continue-on-error: true on the step. It also lets exit code 2 pass.

Troubleshooting

You seeWhyFix
GitLab: cbx-guard job: chosen stage does not exist, and no pipeline startsThe template puts the job in test, and your stages: list has no testSet stage: on cbx-guard to one of your stages, or add test to stages:.
HTTP 422 repo_not_watchedThe token's organisation does not watch the repository on that forgeWatch it in the Console under Repositories.
HTTP 403 account_not_in_orgCBX_GUARD_ACCOUNT is not a cloud account connected to the token's organisationConnect it under Cloud accounts, or set the account that is connected.
HTTP 503 upload_contendedAnother upload for the same pull request kept colliding with this one. Nothing from this upload was recorded or postedRe-run the job. A 503 is safe to retry, and parallel jobs for several roots of one pull request are supported.
HTTP 401The token is wrong, expired or revokedCreate 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 forkExpected. Review the change, then run the plan from a branch in your repository.
GitLab: a merge request from a fork shows no Guard checkIts pipeline ran in the fork, or none ran yetRun 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.

On this page