# ============================================================================ # Binary Paths (Required for Docker Runtime) # ============================================================================ # Terraform binary path (must be executable and match container architecture) # Download a Linux binary matching the container image architecture from https://releases.hashicorp.com/terraform, or use your own copy. # Example for macOS ARM64: /opt/homebrew/bin/terraform # Example for Linux AMD64: /usr/local/bin/terraform TERRAFORM_BINARY_PATH=/path/to/terraform # tfpolicy binary path (must be executable and match container architecture) # Download a Linux binary matching the container image architecture (version 0.3.0 or later) from https://releases.hashicorp.com/tfpolicy, or use your own copy. TFPOLICY_BINARY_PATH=/path/to/tfpolicy # ============================================================================ # Execution Mode: OpenCode # ============================================================================ # --- OpenCode Mode --- # OpenCode supports multiple authentication providers # IMPORTANT: Choose ONE authentication provider below. Do NOT uncomment both sections. # --- OpenCode with GitHub Copilot --- # AUTH_PROVIDER=github-copilot # MODEL_NAME=claude-sonnet-4.6 # GITHUB_COPILOT_ACCESS_TOKEN=gho_your_access_token # GITHUB_COPILOT_REFRESH_TOKEN=gho_your_refresh_token # Optional, defaults to access token # GITHUB_COPILOT_EXPIRES=0 # Optional, defaults to 0 # # Use a model your GitHub Copilot plan offers. Any recent, capable model works well, for example # Claude Sonnet 4.6 or newer, any Claude Opus model or a current GPT model such as gpt-5.2. # Older or smaller models may give lower quality results. # # Note: You can find your GitHub Copilot tokens in: # ~/.local/share/opencode/auth.json (on your host machine) # The container will automatically create auth.json from these environment variables # --- OpenCode with LiteLLM (Default) --- # AUTH_PROVIDER=litellm # MODEL_BASE_URL=https://your-litellm-endpoint.com # MODEL_NAME= # MODEL_API_KEY=sk-your-litellm-api-key # --- OpenCode with Amazon Bedrock (Bearer Token) --- # AUTH_PROVIDER=amazon-bedrock # MODEL_NAME=anthropic.claude-opus-4-5-20251101-v1:0 # MODEL_API_KEY=your-base64-encoded-bedrock-bearer-token # ============================================================================ # External Repository Path (Primary use case) # ============================================================================ # Path to external repository containing Sentinel (.sentinel) or OPA (.rego) policies # Set this to automatically extract and convert policies from an external repository # Can be absolute or relative path # # Examples: # EXTERNAL_REPO_DIR=/Users/xxx/git/company/sentinel-policies # EXTERNAL_REPO_DIR=../../workdir/workspaces/external_repo # EXTERNAL_REPO_DIR=/absolute/path/to/sentinel/repo # # When EXTERNAL_REPO_DIR is set: # - run.sh automatically uses external mode # - .sentinel and .rego files are extracted from this directory (*_test.rego files are skipped) # - Generated policies are deployed to EXTERNAL_REPO_DIR/tfpolicy/ # - Timestamped input/output directories are created automatically # # When EXTERNAL_REPO_DIR is NOT set: # - run.sh uses local mode # - You need to prepare input files manually in DATA_DIR/INPUT_DIR/ EXTERNAL_REPO_DIR=/path/to/your/policy-repository # Path to sentinel.hcl file (Optional) # If specified, the file will be copied and processed during preprocessing # Examples: # SENTINEL_HCL_PATH=/path/to/sentinel.hcl # SENTINEL_HCL_PATH=./external_repo/sentinel.hcl # SENTINEL_HCL_PATH= # ============================================================================ # Pipeline Configuration (for local mode) # ============================================================================ # These settings are used when EXTERNAL_REPO_DIR is not set # Data directory for input/output files (mounted to container's /workspace/data) # Relative paths are resolved from current working directory (where you run the command) # # Examples: # DATA_DIR=./data # Recommended: Create data/ in your working directory # DATA_DIR=/absolute/path/to/data # Use absolute path for clarity # DATA_DIR=../shared-data # Relative to current working directory DATA_DIR=./data # Input subdirectory within DATA_DIR (host-side directory name) # This directory is mounted to container's /workspace/data/input # Examples: # INPUT_DIR=input # Default: data/input/ -> /workspace/data/input # INPUT_DIR=input2 # Alternative: data/input2/ -> /workspace/data/input INPUT_DIR=input # Output subdirectory within DATA_DIR (host-side directory name) # This directory is mounted to container with the same name # Multiple output directories can coexist without interfering with each other # For full pipeline runs and step0-extraction, existing non-empty OUTPUT_DIR is rejected # to prevent accidental overwrite. Set a new OUTPUT_DIR in .env for each new run. # # NOTE: When using external mode, OUTPUT_DIR is automatically generated # with a timestamp (e.g., output-20260603_012345) and this setting is ignored. # This prevents conflicts when processing multiple batches from external repositories. # # Examples: # OUTPUT_DIR=output # Default: data/output/ -> /workspace/data/output # OUTPUT_DIR=output-v2 # Experiment: data/output-v2/ -> /workspace/data/output-v2 # OUTPUT_DIR=results-20260521 # Timestamped: data/results-20260521/ -> /workspace/data/results-20260521 OUTPUT_DIR=output # Input file for policy extraction (Step 0) # Relative to DATA_DIR/INPUT_DIR/ directory # Examples: # INPUT_FILE=policy_goal.txt # Default: DATA_DIR/INPUT_DIR/policy_goal.txt # INPUT_FILE=custom_goals.txt # Custom input file INPUT_FILE=policy_goal.txt # Maximum number of parallel workers for pipeline execution MAX_WORKERS=5 # Optional, defaults to 5 if not set # Container image configuration (pulled from Docker Hub; no login needed) IMAGE_NAME=docker.io/hashicorp/terraform-policy-agent # Public Docker Hub image. Use a different registry path here only to test a staging image IMAGE_TAG=0.0.33 # Pinned image version. Update when you upgrade # Container name prefix for the containers this tool starts # Useful for running multiple environments (dev/staging/prod) or multiple users on the same host # Examples: # CONTAINER_PREFIX=terraform-policy-agent-skills # Default # CONTAINER_PREFIX=dev-pac # Development environment # CONTAINER_PREFIX=staging-pac # Staging environment # CONTAINER_PREFIX=user1-pac # Multi-user setup CONTAINER_PREFIX=terraform-policy-agent-skills # Optional, defaults to terraform-policy-agent-skills (the default container name prefix, not the image name) # ============================================================================ # Container CLI Configuration # ============================================================================ # Container CLI used to build and run the agent: docker (default) or podman # Priority: this .env file > environment variable > built-in default (docker) # Examples: # DOCKER_CLI=docker Use Docker (default) # DOCKER_CLI=podman Use Podman instead # # NOTE: Do not append an inline "#" comment to the line below. The value is # read verbatim by pre_check.py, so a trailing comment becomes part of it. DOCKER_CLI=docker # Extra arguments appended to the container run command (optional) # Use this for host-specific flags that the agent cannot detect on its own. # # IMPORTANT: Wrap the value in double quotes whenever it contains a space. # Without quotes the shell reads only the first word. # # SELinux hosts (RHEL / Fedora / CentOS Stream): # Podman on an SELinux-enforcing host denies the bind mounts unless the # container is permitted to read them. Prefer label=disable over adding ",z" # to the mounts: ",z" relabels the files on the host and would therefore # modify the labels of shared binaries such as /usr/local/bin/terraform. # DOCKER_RUN_EXTRA_ARGS="--security-opt label=disable" # # Rootless Podman on Linux (host.docker.internal is not resolvable): # DOCKER_RUN_EXTRA_ARGS=--add-host=host.docker.internal:host-gateway # # Both of the above at once (SELinux-enforcing Linux host): # DOCKER_RUN_EXTRA_ARGS="--security-opt label=disable --add-host=host.docker.internal:host-gateway" # # Do NOT set --add-host on macOS (Podman Desktop / podman machine): the VM already # defines host.docker.internal, and Podman fails with # 'unable to replace "host-gateway" of host entry "host.docker.internal"'. # # Values are split with shell-style quoting, so paths containing spaces must be # quoted, for example: # DOCKER_RUN_EXTRA_ARGS='-v "/path with spaces:/data:ro"' # The value is parsed, not evaluated: $(...) and backticks are NOT executed. # # DOCKER_RUN_EXTRA_ARGS= # ============================================================================ # Timeout Configuration (in seconds) # ============================================================================ # Stage 0: Policy Extraction timeout STAGE0_TIMEOUT=600 # Optional, defaults to 600 (10 minutes) # Stage 1: Requirement Generation timeout (per goal) STAGE1_TIMEOUT=300 # Optional, defaults to 300 (5 minutes) # Stage 2: Policy Generation timeout (per policy) STAGE2_TIMEOUT=900 # Optional, defaults to 900 (15 minutes) # Note: For complex policies, consider increasing to 900 or more (15 minutes) # Progress heartbeat: seconds between "running" progress lines per stage HEARTBEAT_INTERVAL=30 # Optional, defaults to 30. Set to 0 to disable # Stage 4: Validation Fixtures Generation (Optional) # Enable/disable Stage 4 (validation fixtures generation) ENABLE_STAGE4=false # Optional, defaults to false. Set to true to enable # Stage 4: Validation Fixtures Generation timeout (per policy) STAGE4_TIMEOUT=300 # Optional, defaults to 300 (5 minutes) # Stage 3: Summary Generation timeout # Total timeout = STAGE3_TIMEOUT_BASE + (policy_count * STAGE3_TIMEOUT_PER_POLICY) STAGE3_TIMEOUT_BASE=180 # Optional, defaults to 180 (3 minutes base) STAGE3_TIMEOUT_PER_POLICY=60 # Optional, defaults to 60 (1 minute per policy) # ============================================================================ # Retry Configuration # ============================================================================ # Maximum number of retries for failed tasks # When a task fails (timeout, error, etc.), it will be retried up to MAX_RETRIES times # Note: Retry timeout is automatically increased by 1.5x for each retry attempt # Examples: # MAX_RETRIES=1 # Default: Retry once (total 2 attempts: initial + 1 retry) # MAX_RETRIES=0 # No retries (only initial attempt) # MAX_RETRIES=3 # Retry up to 3 times (total 4 attempts) MAX_RETRIES=1 # Optional, defaults to 1 (backward compatible)