For the complete StackGuardian documentation index, see llms.txt. An extended version with full page content is available at llms-full.txt.
Skip to main content

Infracost integration

Infracost integration​

The Integrations page lets you manage the API keys you use to connect external tools and services to StackGuardian. Currently, Infracost is the only integration available.

With the Infracost integration, you can use your own Infracost API key for cost analysis of Terraform and OpenTofu Workflow runs. By bringing your own key (BYOK), you connect directly to your organization's Infracost account instead of using the default StackGuardian managed key.

Set up the Infracost integration​

  1. Get your Infracost API key. StackGuardian uses this key to authenticate cost estimation requests. If you don't have a key, generate one in your Infracost account.
  2. In StackGuardian, go to SGOrchestrator > Organization settings > Integrations.
  3. In the Infracost Integration card, turn on Activate Infracost Integration organization wide.
  4. In API Key, enter your Infracost API key.
  5. Select Save.

All subsequent Terraform and OpenTofu Workflow runs use this key for cost analysis.

info

After you save, you can't retrieve the Infracost API key from Organization settings.

info

If a Workflow has the INFRACOST_API_KEY environment variable set, it overrides the API key you set in Organization settings.

Frequently asked questions​

Can I switch back to the default StackGuardian Infracost key?

Yes. If you turn off the Infracost integration in Organization settings, StackGuardian uses the default Infracost key again.

Is my Infracost API key secure?

StackGuardian encrypts and stores your Infracost API key securely. After you save it, you can't view it again in Organization settings. StackGuardian accesses the key only while it runs Terraform and OpenTofu Workflow runs.

Why do the Infracost estimations in my Workflow runs fail?
  1. If the Infracost integration is on for your organization, check that the API key is correct and valid.
  2. If the key is valid, check whether the Workflow with the failing runs sets the INFRACOST_API_KEY environment variable. If it does, check that the value is correct.
  3. If the key is correct and valid and the error persists, contact StackGuardian support at support@stackguardian.io.