Skip to content

Analyzer Setup

FinFocus integrates with Pulumi’s analyzer framework as a Policy Pack. This allows you to see real-time cost estimates directly within your pulumi preview and pulumi up workflow.

  • Pulumi CLI installed
  • finfocus binary built (run make build)

Pulumi expects analyzer policy packs to follow a specific naming and directory convention.

Create a dedicated directory to hold your FinFocus policy pack:

Terminal window
mkdir -p ~/.finfocus/analyzer

Create a PulumiPolicy.yaml file in that directory. This file tells Pulumi to use the finfocus runtime.

Terminal window
cat > ~/.finfocus/analyzer/PulumiPolicy.yaml << 'EOF'
runtime: finfocus
name: finfocus
version: 0.3.0
EOF

Copy your finfocus binary to the policy pack directory, renaming it to match Pulumi’s expected naming convention: pulumi-analyzer-policy-<runtime>.

Terminal window
# From the finfocus root directory
cp bin/finfocus ~/.finfocus/analyzer/pulumi-analyzer-policy-finfocus
chmod +x ~/.finfocus/analyzer/pulumi-analyzer-policy-finfocus

To use the analyzer, the binary must be on your PATH and you must point Pulumi to the policy pack directory. Pulumi finds pulumi-analyzer-policy-finfocus by searching PATH — having the binary only in the policy pack directory is not sufficient.

Section titled “Option A: CLI Flag (Recommended for testing)”
Terminal window
export PATH="${HOME}/.finfocus/analyzer:${PATH}"
pulumi preview --policy-pack ~/.finfocus/analyzer
Section titled “Option B: Environment Variable (Recommended for CI/CD)”
Terminal window
export PATH="${HOME}/.finfocus/analyzer:${PATH}"
export PULUMI_POLICY_PACK_PATH="$HOME/.finfocus/analyzer"
pulumi preview

Once configured, cost estimates will appear as advisory diagnostics in your Pulumi output:

Policies:
finfocus@v0.3.0 (local: ~/.finfocus/analyzer)
- [advisory] [severity: low] cost-estimate (aws:ec2/instance:Instance: my-instance)
Estimated Monthly Cost: $7.50 USD (source: finfocus-plugin-aws)
- [advisory] [severity: low] stack-cost-summary (pulumi:pulumi:Stack: my-stack)
Total Estimated Monthly Cost: $7.50 USD (1 resources analyzed)

Ensure:

  1. The binary name in ~/.finfocus/analyzer/ matches exactly: pulumi-analyzer-policy-finfocus.
  2. The directory is on your PATH: export PATH="${HOME}/.finfocus/analyzer:${PATH}". Pulumi searches PATH for the analyzer binary — placing it only in the policy pack directory is not sufficient.
  1. Verify that PulumiPolicy.yaml exists in the same directory as the binary.

  2. Ensure you are passing the correct path to --policy-pack.

  3. Check logs by enabling debug mode:

    Terminal window
    FINFOCUS_LOG_LEVEL=debug pulumi preview --policy-pack ~/.finfocus/analyzer

For a deep dive into how the analyzer works, see the Analyzer Integration Guide.