Skip to main content

Expose Costs

The costs integration allows developers to see their associated costs before applying the terraform. This controller currently uses infracost to extract the predicted costs of a configuration, exposing the cost within the status of the Kubernetes object. It is viewable by running kubectl get configuration.


The costs here are predicted costs, not the actual costs/usage. While many costs can be calculated based on the resource specs alone, many other costs are based on usage. A simple example would be an S3 bucket that is free (predicted cost), but if you store 10TB inside it you will accumulate data storage costs that would not be visible based on your Terraform resource spec.

To configure the integration:

  1. Create a secret containing the Infracost API token.

    $ kubectl -n terraform-system create secret generic infracost \
  2. Configure the controller to enable infracost by updating the controller flag.

    # The name of the secret you created in the controller namespace above
    name: infracost
  3. Update the helm chart.

    $ helm upgrade terranetes-controller charts/

View the predicted costs

The predicted cost of a Configuration is available on the CRD status and resource description.

$ kubectl -n apps get configurations
instance0 $140.96 61s
instance1 $1124.18 61s
instance2 $136.288 61s
instance3 $660.72 61s

You may retrieve the further detail from the status fields as below.

$ k -n apps get  instance0 -o json | jq -r .status.costs
"enabled": true,
"hourly": "$0.1930958904109589",
"monthly": "$140.96"