DellEMC

Fix GCP error Permission ‘storage.buckets.get’ denied

This will be a quick one. I was recently experimenting with creating an S3 bucket GCP using Ansible and I came across this error:

{
  "msg": "GCP returned error: {'error': {'code': 403, 'message': \ansible@vexpose.iam.gserviceaccount.com does not have storage.buckets.get access to the Google Cloud Storage bucket. Permission 'storage.buckets.get' denied on resource (or it may not exist).\, 'errors': [{'message': \ansible@vexpose.iam.gserviceaccount.com does not have storage.buckets.get access to the Google Cloud Storage bucket. Permission 'storage.buckets.get' denied on resource (or it may not exist).\, 'domain': 'global', 'reason': 'forbidden'}]}}",
  "invocation": {
    "module_args": {
      "name": "gcp_s3",
      "project": "vexpose",
      "auth_kind": "serviceaccount",
      "storage_class": "COLDLINE",
... <<< output truncated >>>

After seeing “Permission Denied” I naturally started to look at the roles that were assigned to the account . I discovered later that the “Storage Admin” role provided already that permission, but in the process I wasted some precious time adding other roles that provided that permission yet again. So I felt compelled to write this quick post to help other people save their time.

If this is happening to you the resolution could be quite simple. We must remember that GCP (like other public cloud providers) uses a single namespace for all customers. Therefore the bucket name must be “universally” unique. If it isn’t it takes it as you are trying to make changes to an existing bucket that another customer owns and it throws the misleading “permission denied” error. So, simply choose a more complex name and see if that fixes the error.

You can quickly test if it is an issue with your name not being unique by trying to create a bucket using GCP web interface for example. It if is already taken you will receive a message like this.

Categories: DellEMC

Tagged as: , , , , , ,

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.