最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin8PV0评论

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.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far