CLI Reference
StackSage is installed via pip and runs entirely on your machine. It has two commands:
| Command | Requires license? | Use case |
|---|---|---|
stacksage scan | No | Self-serve: run locally or in CI. Free tier shows top 50 findings by savings. |
stacksage audit | Yes (STACKSAGE_LICENSE) | Licensed: all findings + remediation plan. Designed for CI/CD pipelines. |
Installation
pip install stacksagestacksage scan
Scans your AWS account, analyses waste, estimates savings, and opens an HTML report in your browser. No license required — free tier shows your top 50 findings ranked by estimated monthly savings. Security & posture checks are always shown in full.
stacksage scan [OPTIONS]Options
| Option | Default | Description |
|---|---|---|
--profile TEXT | — | AWS named profile or SSO profile (e.g. my-sso-profile). Uses default credentials if omitted. |
--role-arn TEXT | — | Assume this read-only IAM role ARN. Takes precedence over --profile. |
--external-id TEXT | — | ExternalId to pass when assuming the role (optional). |
--regions TEXT | all enabled | Comma-separated AWS regions to scan, e.g. us-east-1,eu-west-1. |
--out DIRECTORY | reports/ | Directory to write report files into. |
--use-cloudwatch | off | Enable CloudWatch utilisation metrics for more accurate findings (recommended). |
--use-cost-explorer | off | Include historical spend summary from Cost Explorer. |
--check-tagging | off | Flag resources missing required tags (opt-in to reduce noise). |
--cw-days INTEGER | 14 | CloudWatch metrics lookback window in days. |
--cw-max-queries INTEGER | 500 | Maximum CloudWatch API calls per run. Findings that hit the cap are flagged as skipped-budget. |
--no-browser | off | Do not auto-open the HTML report in a browser after the scan. |
--demo | off | Run with synthetic data — no AWS calls or credentials needed. |
--log-level TEXT | INFO | Structured JSON log verbosity: DEBUG, INFO, WARNING, ERROR. |
--quiet | off | Suppress progress output. |
Examples
Default credentials
stacksage scanNamed AWS profile or SSO
stacksage scan --profile my-sso-profileCross-account read-only role
stacksage scan --role-arn arn:aws:iam::123456789012:role/StackSageReadOnlyRecommended flags for a thorough scan
stacksage scan --use-cloudwatch --use-cost-explorer --check-taggingSpecific regions, no browser
stacksage scan --regions us-east-1,eu-west-1 --no-browserUnlock all findings with a license
export STACKSAGE_LICENSE=your-license-key
stacksage scanstacksage audit
Runs a full licensed audit. Requires a valid license key in the STACKSAGE_LICENSE environment variable. Unlocks all findings, the full remediation plan, and every report section. Designed for CI/CD pipelines and scheduled audits.
STACKSAGE_LICENSE=your-key stacksage audit [OPTIONS]Options
| Option | Default | Description |
|---|---|---|
--profile TEXT | — | AWS named profile or SSO profile. Uses default credentials if omitted. |
--role-arn TEXT | — | Assume this read-only IAM role ARN. Takes precedence over --profile. |
--external-id TEXT | — | ExternalId to pass when assuming the role (optional). |
--regions TEXT | all enabled | Comma-separated AWS regions to scan. |
--out DIRECTORY | reports/ | Directory to write report files into. |
--format [html|json] | html | Output format. json prints the raw findings object. |
--use-cloudwatch | off | Enable CloudWatch utilisation metrics (recommended). |
--use-cost-explorer | off | Include historical spend summary from Cost Explorer. |
--live | off | Convenience flag: enables --use-cloudwatch, --use-cost-explorer, and --live-pricing in one flag. |
--check-tagging | off | Flag resources missing required tags (opt-in). |
--cw-days INTEGER | 14 | CloudWatch metrics lookback window in days. |
--cw-max-queries INTEGER | 500 | Maximum CloudWatch API calls per run. |
--live-pricing | off | Use the live AWS Pricing API for EC2 rates (default: static prices). |
--demo | off | Run with synthetic data — useful for testing the pipeline. |
--log-level TEXT | INFO | DEBUG, INFO, WARNING, ERROR. |
--quiet | off | Suppress progress output (errors only). |
Examples
Basic licensed audit
export STACKSAGE_LICENSE=your-license-key
stacksage audit --profile my-sso-profile --use-cloudwatch --use-cost-explorerCross-account role in CI
STACKSAGE_LICENSE=$LICENSE stacksage audit \
--role-arn arn:aws:iam::123456789012:role/StackSageReadOnly \
--use-cloudwatch --use-cost-explorer \
--out ./resultsFull live mode (CloudWatch + Cost Explorer + live pricing)
STACKSAGE_LICENSE=$LICENSE stacksage audit --live --out ./resultsGitHub Actions workflow snippet
- name: Run StackSage audit
env:
STACKSAGE_LICENSE: ${{ secrets.STACKSAGE_LICENSE }}
run: |
stacksage audit \
--role-arn arn:aws:iam::123456789012:role/StackSageReadOnly \
--use-cloudwatch --use-cost-explorer \
--out ./results
- name: Upload report
uses: actions/upload-artifact@v4
with:
name: stacksage-report-${{ github.run_number }}
path: results/
retention-days: 30See the GitHub Actions setup guide for the full workflow including OIDC role assumption.
JSON output for downstream processing
STACKSAGE_LICENSE=$LICENSE stacksage audit --format json --out ./resultsEnvironment variables
| Variable | Description |
|---|---|
STACKSAGE_LICENSE | License key. Required for stacksage audit. Also unlocks all findings in stacksage scan. |
STACKSAGE_PRICING_MODE | Set to api to use the live AWS Pricing API for EC2 rates (default: static). |
AWS_PROFILE | Standard AWS profile env var — respected by StackSage. |
AWS_DEFAULT_REGION | Standard AWS region env var — respected by StackSage. |