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:
Create a secret containing the Infracost API token.
$ kubectl -n terraform-system create secret generic infracost \
Configure the controller to enable infracost by updating the controller flag.
# The name of the secret you created in the controller namespace above
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
NAME MODULE SECRET RESOURCES ESTIMATED AGE
instance0 https://github.com/terraform-aws-modules/terraform-aws-ec2-instance.git $140.96 61s
instance1 https://github.com/terraform-aws-modules/terraform-aws-ec2-instance.git $1124.18 61s
instance2 https://github.com/terraform-aws-modules/terraform-aws-ec2-instance.git $136.288 61s
instance3 https://github.com/terraform-aws-modules/terraform-aws-ec2-instance.git $660.72 61s
You may retrieve the further detail from the status fields as below.
$ k -n apps get configurations.terraform.appvia.io instance0 -o json | jq -r .status.costs