The API described in this page can be useful for CI/CD integrations, such as Atlantis, where it might be easier to use
curl or an HTTP library instead of installing the Infracost CLI. Terraform plan JSON files can be sent to this API, which runs
infracost diff and returns the results (
text/plain response). Whilst this API deletes files from the server after they are processed, it is a good security practice to remove secrets from the file before sending it to the API. For example, AWS provides a grep command that can be used to do this.
To use this API, send an HTTP POST request to https://pricing.api.infracost.io/terraform-json-file with the
terraform-json-file parameter using the multipart/form-data request body format, as shown in the following example curl request. The
x-api-key header must be set to your Infracost API key.
|terraform-json-file||Terraform plan JSON file||Required. Use '@' to upload the file with curl, e.g. |
|usage-file||Infracost usage file that specifies values for usage-based resources||Not required. Use '@' to upload the file with curl, e.g. |
|show-skipped||Show unsupported resources, some of which might be free.||Not required. Defaults to false|
|no-color||Turn off colored output, useful for CI/CD or Windows users (color output has a bug we need to fix on Windows)||Not required. Defaults to false|
- Example request