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.
Prerequisites
Section titled “Prerequisites”- Pulumi CLI installed
finfocusbinary built (runmake build)
Setup Instructions
Section titled “Setup Instructions”Pulumi expects analyzer policy packs to follow a specific naming and directory convention.
1. Create a Policy Pack Directory
Section titled “1. Create a Policy Pack Directory”Create a dedicated directory to hold your FinFocus policy pack:
mkdir -p ~/.finfocus/analyzer2. Configure the Policy Pack
Section titled “2. Configure the Policy Pack”Create a PulumiPolicy.yaml file in that directory. This file tells Pulumi to use the finfocus runtime.
cat > ~/.finfocus/analyzer/PulumiPolicy.yaml << 'EOF'runtime: finfocusname: finfocusversion: 0.3.0EOF3. Install the Binary
Section titled “3. Install the Binary”Copy your finfocus binary to the policy pack directory, renaming it to match Pulumi’s expected naming convention:
pulumi-analyzer-policy-<runtime>.
# From the finfocus root directorycp bin/finfocus ~/.finfocus/analyzer/pulumi-analyzer-policy-finfocuschmod +x ~/.finfocus/analyzer/pulumi-analyzer-policy-finfocus4. Enable the Analyzer
Section titled “4. Enable the Analyzer”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.
Option A: CLI Flag (Recommended for testing)
Section titled “Option A: CLI Flag (Recommended for testing)”export PATH="${HOME}/.finfocus/analyzer:${PATH}"pulumi preview --policy-pack ~/.finfocus/analyzerOption B: Environment Variable (Recommended for CI/CD)
Section titled “Option B: Environment Variable (Recommended for CI/CD)”export PATH="${HOME}/.finfocus/analyzer:${PATH}"export PULUMI_POLICY_PACK_PATH="$HOME/.finfocus/analyzer"pulumi previewOnce 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)Troubleshooting
Section titled “Troubleshooting””could not start policy pack”
Section titled “”could not start policy pack””Ensure:
- The binary name in
~/.finfocus/analyzer/matches exactly:pulumi-analyzer-policy-finfocus. - 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.
No cost diagnostics appear
Section titled “No cost diagnostics appear”-
Verify that
PulumiPolicy.yamlexists in the same directory as the binary. -
Ensure you are passing the correct path to
--policy-pack. -
Check logs by enabling debug mode:
Terminal window FINFOCUS_LOG_LEVEL=debug pulumi preview --policy-pack ~/.finfocus/analyzer
Technical Details
Section titled “Technical Details”For a deep dive into how the analyzer works, see the Analyzer Integration Guide.