If storage_bucket is present in configuration on behalf SA with only storage.editor permission (which is suggested in the provider documentation), than subsequent plan / apply operations become extremely slow.
This happens because provider reads bucket policy and retries, among others, authorization errors. But request fails (this is fragment of output I got when running with TF_LOG=debug):
And, of course, it fails consistently, because storage.editor does not have permission to call GetBucketPolicy (adding storage.configViewer makes this issue go away).
So request is retried for, AFAICT, one minute. After this minute passes, provider silently proceeds as if it successfully fetched policy and it is empty.
Also note that interrupting plan or apply with Ctrl-C also works slowly, likely because ctx is not propagated by the retryOnAwsCodes(). (UPD: it seems that resource.Retry is deprecated anyway with RetryContext as suggested alternative)
In my opinion, current behavior is very confusing.
As an alternative, a new flag can be added to storage_bucket resource, e.g. skip_policy. When this flag is set to true, provider does not manage bucket policy (e.g. neither reads nor writes it). And when flag is not set, provider does not ignore errors when reading policy. This way both storage.admin and storage.editor roles can be used for managing bucket, and users can't get into unexpected slowdowns.
Also it seems that documentation should be updated to mention both storage.editor and storage.configViewer roles.
If
storage_bucket
is present in configuration on behalf SA with onlystorage.editor
permission (which is suggested in the provider documentation), than subsequentplan
/apply
operations become extremely slow.This happens because provider reads bucket policy and retries, among others, authorization errors. But request fails (this is fragment of output I got when running with
TF_LOG=debug
):And, of course, it fails consistently, because
storage.editor
does not have permission to call GetBucketPolicy (addingstorage.configViewer
makes this issue go away).So request is retried for, AFAICT, one minute. After this minute passes, provider silently proceeds as if it successfully fetched policy and it is empty.
Also note that interrupting
plan
orapply
withCtrl-C
also works slowly, likely becausectx
is not propagated by theretryOnAwsCodes()
. (UPD: it seems thatresource.Retry
is deprecated anyway withRetryContext
as suggested alternative)In my opinion, current behavior is very confusing.
As an alternative, a new flag can be added to
storage_bucket
resource, e.g.skip_policy
. When this flag is set to true, provider does not manage bucket policy (e.g. neither reads nor writes it). And when flag is not set, provider does not ignore errors when reading policy. This way bothstorage.admin
andstorage.editor
roles can be used for managing bucket, and users can't get into unexpected slowdowns.Also it seems that documentation should be updated to mention both
storage.editor
andstorage.configViewer
roles.