Problem
When using the cost estimation feature in a Terraform Enterprise instance hosted on Google Cloud Platform (GCP), you may encounter the following panic error during a plan.
panic: could not create Instance resolver: googleapi: Error 403: Cloud Billing API has not been used in project XXXXXXXXXXX before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudbilling.googleapis.comthen retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
Cause
This error occurs because the GCP Cloud Billing API is not enabled by default in new GCP projects. Terraform Enterprise requires this API to be active to perform cost estimation calculations for GCP resources.
Solution
To resolve this issue, you must enable the Cloud Billing API in the specific GCP project associated with your Terraform Enterprise workspace.
Procedure
- Navigate to the Google Cloud Billing API page in the Google Cloud Console.
- Ensure you have selected the correct GCP project where your resources are deployed.
- Click the Enable button to activate the API for your project.
- Wait a few minutes for the change to propagate throughout Google Cloud's systems.
- Rerun the plan in your Terraform Enterprise workspace. The cost estimation should now complete successfully.
Additional Information
For more details on configuring and using this feature, please refer to the official documentation on cost estimation in Terraform Enterprise.