-
-
Notifications
You must be signed in to change notification settings - Fork 376
GCP: No upfront validation of project ID causes noisy error output #1053
Description
Description
When running cloud-nuke gcp --project-id <id> with an invalid or non-existent project ID, cloud-nuke proceeds to scan all GCP resources and produces one error per resource type instead of failing immediately with a clear message.
With 2 current GCP resources this produces 2 error rows. As more GCP resources are added this will become increasingly noisy and confusing, the same root cause (invalid project ID) buried under N error rows.
Steps to Reproduce
- Run
cloud-nuke gcp --project-id invalid-gcp-project - Observe one error row per GCP resource type in the output
Note: The broken table rendering in the screenshot is a known issue tracked separately: #1049
Expected Behavior
cloud-nuke should validate the project ID upfront before scanning anything and fail immediately with a clear message:
Error: GCP project <project-id> does not exist or is not accessible with the provided credentials.
Proposed Fix
Add a pre-flight check in commands/gcp_commands.go using google.golang.org/api/cloudresourcemanager/v3 (already a dependency, no new module needed) to call GetProject before GetAllResources. One API call that catches:
- Project does not exist
- Credentials don't have access to the project
- Project is already in
DELETE_REQUESTEDstate