最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

AccessDeniedException when trying to delete a file from Google Cloud Storage despite having Storage Admin role - Stack Overflow

programmeradmin7浏览0评论

I am facing an AccessDeniedException (403 Access Denied) when trying to delete a file from a Google Cloud Storage bucket. I have assigned the necessary permissions and roles (Storage Admin), but I still can't remove the object.

Steps taken:

IAM Permissions:

The service account has been granted the roles/storage.objectAdmin role on the bucket. My account has both Editor and Storage Admin roles in the project.

Bucket Policy Only:

I checked the bucket's settings and found that Bucket Policy Only is enabled. The Bucket Policy Only feature is locked until a specific future date.

Attempts to Remove the Object:

I attempted to remove a file from the bucket using the gsutil rm command. I received the error: AccessDeniedException: 403 Access denied.

Verification:

I have verified that no retention policy is set, and there is no object lock. I tried disabling Bucket Policy Only using the gcloud command but encountered errors because the option to disable was not recognized.

Current IAM Policy for the Bucket:

 - members:
 - projectEditor:project-id
 - projectOwner:project-id
  role: roles/storage.legacyBucketOwner
 - members:
 - projectViewer:project-id
  role: roles/storage.legacyBucketReader
 - members:
 - projectEditor:project-id
 - projectOwner:project-id
  role: roles/storage.legacyObjectOwner
 - members:
 - projectViewer:project-id
  role: roles/storage.legacyObjectReader
 - members:
 - serviceAccount:service-account-id
  role: roles/storage.objectAdmin

What I have tried:

  • Adding the storage.objectAdmin role to the service account.

  • Disabling Bucket Policy Only using the gcloud command, but it does not recognize the option.

  • Checking the bucket's permissions and object lock status.

Error Message:

gsutil rm gs://bucket-name/file-name
Removing gs://bucket-name/file-name...
AccessDeniedException: 403 Access denied.

I am facing an AccessDeniedException (403 Access Denied) when trying to delete a file from a Google Cloud Storage bucket. I have assigned the necessary permissions and roles (Storage Admin), but I still can't remove the object.

Steps taken:

IAM Permissions:

The service account has been granted the roles/storage.objectAdmin role on the bucket. My account has both Editor and Storage Admin roles in the project.

Bucket Policy Only:

I checked the bucket's settings and found that Bucket Policy Only is enabled. The Bucket Policy Only feature is locked until a specific future date.

Attempts to Remove the Object:

I attempted to remove a file from the bucket using the gsutil rm command. I received the error: AccessDeniedException: 403 Access denied.

Verification:

I have verified that no retention policy is set, and there is no object lock. I tried disabling Bucket Policy Only using the gcloud command but encountered errors because the option to disable was not recognized.

Current IAM Policy for the Bucket:

 - members:
 - projectEditor:project-id
 - projectOwner:project-id
  role: roles/storage.legacyBucketOwner
 - members:
 - projectViewer:project-id
  role: roles/storage.legacyBucketReader
 - members:
 - projectEditor:project-id
 - projectOwner:project-id
  role: roles/storage.legacyObjectOwner
 - members:
 - projectViewer:project-id
  role: roles/storage.legacyObjectReader
 - members:
 - serviceAccount:service-account-id
  role: roles/storage.objectAdmin

What I have tried:

  • Adding the storage.objectAdmin role to the service account.

  • Disabling Bucket Policy Only using the gcloud command, but it does not recognize the option.

  • Checking the bucket's permissions and object lock status.

Error Message:

gsutil rm gs://bucket-name/file-name
Removing gs://bucket-name/file-name...
AccessDeniedException: 403 Access denied.

Share Improve this question edited Nov 16, 2024 at 19:41 Doug Stevenson 319k36 gold badges456 silver badges473 bronze badges asked Nov 16, 2024 at 19:39 AdhilAdhil 238 bronze badges 1
  • Disabling Bucket Policy Only using the gcloud command, but it does not recognize the option. What do you mean with "it does not recognize the option"? What option? could you share the output? Also, what is the account executing the gsutil rm command? – MrThompson Commented Nov 16, 2024 at 21:44
Add a comment  | 

1 Answer 1

Reset to default 0

As you did not mention it in your post: maybe you just fot to activate the service account?

gcloud auth activate-service-account [ACCOUNT] --key-file=KEY_FILE

also, make sure that you have correct permissions to impersonate the SA you want to use.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论