Terraform policy reference overview
This section provides detailed reference documentation for Terraform policy, including CLI commands, policy configuration syntax, functions, and test configuration syntax.
CLI Reference
The Terraform policy CLI (tfpolicy) provides commands for validating and testing your policies locally.
- CLI overview: Global flags and command overview
tfpolicy test: Run policy teststfpolicy validate: Validate policy syntaxtfpolicy version: Display version information
Policy configuration reference
Reference documentation for policy file syntax and configuration blocks.
- Policy configuration overview - Overview of policy file syntax
- The
policyblock - Configure Terraform Policy - The
provider_policyblock - Write provider policies - The
resource_policyblock - Write resource policies - The
module_policyblock - Write module policies - The
inputblock - Define input variables - The
localsblock - Define local values
Test configuration reference
Reference documentation for policy test file syntax and configuration blocks.
- Test configuration overview - Overview of test file syntax
- The
policytestblock - Configure test targets - Mock provider blocks - Define mock providers
- Mock resource blocks - Define mock resources
- Mock data source blocks - Define mock data sources
- Mock module blocks - Define mock modules
- The
inputsblock - Set input values for tests - The
localsblock - Define local values for tests
Operators reference
Reference documentation for the operators available in policy and test files
- Operators: Arithmetic, comparison, and logical operators
Functions reference
Reference documentation for built-in and plugin functions.
- Functions overview: Overview of available functions
core::getresources: Fetch resourcescore::getdatasource: Fetch data sourcescore::gethttprequest: Make HTTP requestscore::semverconstraint: Validate semantic versions