CrowdStrike / cloud-resource-estimator

Cloud deployment size calculation utilities
The Unlicense
17 stars 19 forks source link

Enhance script to gracefully handle errors #40

Closed gadouryd closed 1 month ago

gadouryd commented 2 months ago

When running the estimator in GCP the below error was received which caused the script to fail. Please update to gracefully error handle when encountering disabled services.

""Kubernetes Engine API has not been used in project project-name before or it is disabled. "

2024-07-08 19:05:32 INFO Exploring GCP project: ##### Traceback (most recent call last): File "/home/user/cloudshell_open/cloud-resource-estimator/cloud-benchmark/gcp_cspm_benchmark.py", line 102, in row = process_gcp_project(project) File "/home/user/cloudshell_open/cloud-resource-estimator/cloud-benchmark/gcp_cspm_benchmark.py", line 76, in process_gcp_project for cluster in gcp.clusters(project.project_id): File "/home/user/cloudshell_open/cloud-resource-estimator/cloud-benchmark/gcp_cspm_benchmark.py", line 44, in clusters response = request.execute() File "/home/user/cloudshell_open/cloud-resource-estimator/cloud-benchmark/lib/python3.10/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper return wrapped(*args, **kwargs) File "/home/user/cloudshell_open/cloud-resource-estimator/cloud-benchmark/lib/python3.10/site-packages/googleapiclient/http.py", line 938, in execute raise HttpError(resp, content, uri=self.uri) googleapiclient.errors.HttpError: <HttpError 403 when requesting https://container.googleapis.com/v1/projects/project-name/zones/-/clusters?alt=json [container.googleapis.com] returned "Kubernetes Engine API has not been used in project project-name before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/container.googleapis.com/overview?project=project-name [console.developers.google.com] then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.". Details: "[{'@type': 'type.googleapis.com/google.rpc.Help [type.googleapis.com]', 'links': [{'description': 'Google developers console API activation', 'url': 'https://console.developers.google.com/apis/api/container.googleapis.com/overview?project=project-name [console.developers.google.com]'}]}, {'@type': 'type.googleapis.com/google.rpc.ErrorInfo [type.googleapis.com]', 'reason': 'SERVICE_DISABLED', 'domain': 'googleapis.com [googleapis.com]', 'metadata': {'consumer': 'projects/project-name', 'service': 'container.googleapis.com [container.googleapis.com]'}}]">