Skip to content

GCP: No upfront validation of project ID causes noisy error output #1053

@Amit2465

Description

@Amit2465

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

  1. Run cloud-nuke gcp --project-id invalid-gcp-project
  2. Observe one error row per GCP resource type in the output
Image

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_REQUESTED state

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions