HashiConf Our community conference is taking place in San Francisco and online October 10-12. Register now
  • Infrastructure
    • terraform
    • packer
  • Networking
    • consul
  • Security
    • vault
    • boundary
  • Applications
    • nomad
    • waypoint
    • vagrant
  • HashiCorp Cloud Platform

    A fully managed platform to automate infrastructure on any cloud with HashiCorp products.

    • consul
    • terraform
    • vault
    • packerbeta
    Visit cloud.hashicorp.com
Sentinel
  • Intro
  • Docs
Download
    • v0.21.x (latest)
    • v0.20.x
    • v0.19.x
    • v0.18.x
    • v0.17.x
    • v0.16.x
    • v0.15.x
    • v0.14.x
    • v0.13.x
  • Release Notes
    • Overview
    • Policy as Code
    • Policy Language
    • Imports
    • Enforcement Levels
    • Overview
    • Override Files
    • Remote Sources
    • Overview
    • apply
    • fmt
    • test
    • Overview
    • Basics
    • Rules
    • Traces
    • Testing
    • Imports
    • Debugging
    • Overview
    • Modules
    • Plugins
    • Static Imports
    • Internals

    • Overview
    • Variables
    • Values
    • Lists
    • Maps
    • Rules
    • Imports
    • Parameters
    • Boolean Expressions
    • Arithmetic
    • Slices
    • Conditionals
    • Loops
    • Collection Operations
    • Functions
    • Scope
    • Undefined
    • Logging and Errors
    • Specification
    • Overview
    • append
    • delete
    • error
    • keys
    • length
    • print
    • range
    • values
    • Overview
    • base64
    • decimal
    • http
    • json
    • runtime
    • sockaddr
    • strings
    • time
    • types
    • units
    • version

  • Consul
  • Nomad
  • Terraform
  • Vault
Type '/' to Search

»Language: Logging and Errors

The built-in functions print and error can be used for logging and errors. Logging is helpful to understand how a policy is executing in development. And errors are useful to halting execution immediately in certain scenarios.

»Print

The print function is used to output debug information. The exact location where this print statements go is dependent on the host application and the Sentinel runtime itself.

The print function takes zero or more Sentinel values as arguments. Each value is formatted for human-friendly output and space-separated. Example:

value = 42
print("the value is", value) // the value is 42

map = { "foo": false }
print(map) // { "foo": false }

one_is_zero = rule { 1 == 0 }
print(one_is_zero) // false

»Errors

Certain actions in Sentinel, such as accessing an undefined variable, attempting to add two incompatible types, etc. result in runtime errors. These errors halt the execution of a policy immediately. The pass/fail result of a policy is considered fail.

Runtime errors can be manually triggered using the error function. The error function behaves exactly like the print function except that execution is halted immediately.

This should only be used in scenarios where the policy must fail due to some unexpected or invalid condition. The line between error and undefined can sometimes be unclear. Undefined is recommended when a policy can conceivably recover or safely ignore the undefined behavior. An error should be used when the policy should fail and notify someone regardless.

  • ProvisionMulti-Cloud Infrastructure
  • SecureMulti-Cloud Security
  • ConnectMulti-Cloud Networking
  • RunMulti-Cloud Orchestration
Products
  • Terraform
  • Vault
  • Consul
  • Nomad
  • Vagrant
  • Packer
  • Boundary NEW
  • Waypoint NEW
  • Sentinel
Resources
  • Blog
  • Tutorials
  • Community
  • Events
  • Integrations
  • Library
  • Partners
  • Podcast
  • Support
  • Training
Company
  • About Us
  • JobsWe're Hiring
  • Press Center
  • Brand
  • Contact Us
  • System Status
  • Cookie Manager
  • Terms of Use
  • Security
  • Privacy
  • Trademark Policy
stdin: is not a tty