Skip to content

Commit db0534f

Browse files
Fix Service Account creation by ignoring 403 errors on read polling (#11811) (#8336)
[upstream:e6af55b2acc4c621678faebccfa6009420f87b17] Signed-off-by: Modular Magician <[email protected]>
1 parent fa15c26 commit db0534f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Diff for: .changelog/11811.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
iam: addressed `google_service_account` creation issues caused by the eventual consistency of the GCP IAM API by ignoring 403 errors returned on polling the service account after creation.
3+
```

Diff for: google-beta/services/resourcemanager/resource_google_service_account.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ func resourceGoogleServiceAccountCreate(d *schema.ResourceData, meta interface{}
154154

155155
// We poll until the resource is found due to eventual consistency issue
156156
// on part of the api https://cloud.google.com/iam/docs/overview#consistency
157-
err = transport_tpg.PollingWaitTime(resourceServiceAccountPollRead(d, meta), transport_tpg.PollCheckForExistence, "Creating Service Account", d.Timeout(schema.TimeoutCreate), 1)
157+
// IAM API returns 403 when the queried SA is not found, so we must ignore both 404 & 403 errors
158+
err = transport_tpg.PollingWaitTime(resourceServiceAccountPollRead(d, meta), transport_tpg.PollCheckForExistenceWith403, "Creating Service Account", d.Timeout(schema.TimeoutCreate), 1)
158159

159160
if err != nil {
160161
return err

0 commit comments

Comments
 (0)