Resourcely-cli
resourcely-cli
is a command line utility that helps Resourcely evaluate Guardrails against Terraform plans. It runs in on your infrastructure, typically a CI/CD runner, and only sends lightweight metadata about Guardrail violations back to Resourcely.
This page describes general resourcely-cli
concepts that apply to any runner.
Running the CLI
resourcely-cli
is available as a Docker container or as a self-contained binary. Individual users never need to run resourcely-cli
manually. See CI/CD & Terraform Runners for how to configure various CI systems to run resourcely-cli
automatically.
JSON output
resourcely-cli
can produce a JSON file with finding details. You can consume them in code that gathers statistics, sends slack messages, etc. Pass --output_file <filename>
to enable this feature.
Here is an example file with comments describing each field:
Advanced usage
If you use .resourcely.yaml to define multiple config roots (and optionally, environments), you probably need to use resourcely-cli
to evaluate multiple plans, one per config root (and environment).
Below, we'll use the following resourcely.yaml in examples:
Running resourcely-cli with many plans
You can run resourcely-cli
with several plans at once. For each plan, you must specify the config root (and environment, if applicable). Resourcely uses these values to merge findings from each plan and determine when it can approve the pull request.
Note: The values of --config_root_path
and --environment
must match the corresponding path
and name
fields in resourcely.yaml
.
Examples:
You can pass --error_on_violations
parameter to Resourcely-cli if you want it to exist with non-zero when it finds guardrail violations
Multiple runs of resourcely-cli
Some CI/CD setups can't access every plan in one place, so they must run resourcely-cli
multiple times. After each run of resourcely-cli
, Resourcely will merge findings from that run over any prior findings, using the config root and (optionally) environment as the key.
An example for the sake of demonstrating the merge logic:
You can pass --output_file
to write findings to a file (as json)
Pull request approval
When a pull request is created, Resourcely computes the set of plans that it expects to receive findings from. Resourcely will only approve the pull request once it has received findings from every plan for the PR's latest commit.
Resourcely computes the set of expected plans based on which files the pull request has changed:
If the PR changes a
.tf
file in a config root......if that config root does not have environments, Resourcely expects one plan from it.
...otherwise, Resourcely expects one plan from each of its environments.
Additionally, if the PR changes a
.tfvars
file listed inresourcely.yaml
, Resourcely expects one plan from that config root and environment.
Examples:
Last updated