From 3aafb4bdbbabf621d65cbb5cb69df3a3598a08a3 Mon Sep 17 00:00:00 2001 From: vj Date: Wed, 29 Jan 2025 13:46:36 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20gracefully=20handle=20403=20when?= =?UTF-8?q?=20fetching=20gcp=20org?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- providers/gcp/resources/organization.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/providers/gcp/resources/organization.go b/providers/gcp/resources/organization.go index 5a063ff7e..aa8c1eb6d 100644 --- a/providers/gcp/resources/organization.go +++ b/providers/gcp/resources/organization.go @@ -17,6 +17,7 @@ import ( "github.com/rs/zerolog/log" "google.golang.org/api/cloudresourcemanager/v3" "google.golang.org/api/compute/v1" + "google.golang.org/api/googleapi" "google.golang.org/api/iam/v1" "google.golang.org/api/option" ) @@ -60,6 +61,12 @@ func initGcpOrganization(runtime *plugin.Runtime, args map[string]*llx.RawData) name := "organizations/" + orgId org, err := svc.Organizations.Get(name).Do() if err != nil { + if e, ok := err.(*googleapi.Error); ok { + if e.Code == 403 { + log.Error().Err(err).Msg("cannot fetch organization info") + return nil, nil, errors.New("403: permission denied") + } + } return nil, nil, err }