Skip to content

Commit

Permalink
Check for errors in google_project datasource Read results (#7036) (#…
Browse files Browse the repository at this point in the history
…13358)

Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Dec 28, 2022
1 parent 2ad8dfe commit f5c58e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/7036.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resourcemanager: fixed the `google_project` datasource silently returning empty results when the project was not found or not in the ACTIVE state. Now, an error will be surfaced instead.
```
12 changes: 11 additions & 1 deletion google/data_source_google_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,15 @@ func datasourceGoogleProjectRead(d *schema.ResourceData, meta interface{}) error
d.SetId(fmt.Sprintf("projects/%s", project))
}

return resourceGoogleProjectRead(d, meta)
id := d.Id()

if err := resourceGoogleProjectRead(d, meta); err != nil {
return err
}

if d.Id() == "" {
return fmt.Errorf("%s not found or not in ACTIVE state", id)
}

return nil
}

0 comments on commit f5c58e5

Please sign in to comment.