Skip to content

Commit

Permalink
🧹 gracefully handle 403 when fetching gcp org (#5136)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjeffrey authored Jan 31, 2025
1 parent 05f5a47 commit 4c1b4a0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions providers/gcp/resources/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 4c1b4a0

Please sign in to comment.