Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Bucket Policy Only #80

Open
ntopulos opened this issue Nov 1, 2019 · 13 comments
Open

Error: Bucket Policy Only #80

ntopulos opened this issue Nov 1, 2019 · 13 comments

Comments

@ntopulos
Copy link

ntopulos commented Nov 1, 2019

Google Cloud Storage buckets have an option to define access control on the whole bucket instead of the per object approach:

Set permissions uniformly at bucket-level (Bucket Policy Only)
Enforces the bucket’s IAM policy without object ACLs. May help prevent unintended access. If selected, this option becomes permanent after 90 days.

Using such a bucket results in error:

Cannot use ACL API to set object policy when object policies are disabled.

Is this package compatible with these buckets?

@LorenzoSapora
Copy link

I just hit this too, I was able to upload a period ago (I don't remember, mine is a development server, so I can't place exactly when I last used the upload functionality).

But, I know nothing has changed in terms of my GCP buckets, or my GCS integration.

@LorenzoSapora
Copy link

Possibly related to this? I see that superbalist/laravel-google-cloud-storage uses superbalist/flysystem-google-cloud-storage which uses google/cloud-storage, as this stackoverflow question states.

The dates aren't exactly close (11 months) but might be something to start with.

@LorenzoSapora
Copy link

Sorry for the comment spam, but my issue was solved by changing the bucket access controls to 'fine grained' verses 'uniform'.
image

Hope this helps (although brings up the issue of buckets that use uniform permissions..)

@tao
Copy link

tao commented Mar 9, 2020

I found this problem too.

{ "error": { "code": 400, "message": "Cannot insert legacy ACL for an object when uniform bucket-level access is enabled. Read more at https://cloud.google.com/storage/docs/uniform-bucket-level-access.", "errors": [ { "message": "Cannot insert legacy ACL for an object when uniform bucket-level access is enabled. Read more at https://cloud.google.com/storage/docs/uniform-bucket-level-access.", "domain": "global", "reason": "invalid" } ] } }

@prazian
Copy link

prazian commented Mar 17, 2020

I got the same error, any thoughts guys?

@LorenzoSapora
Copy link

Did you try my solution @prazian (and possibly @tao, too)

@prazian
Copy link

prazian commented Mar 17, 2020

Thank you @LorenzoSapora for the prompt response. 🙂

Is it possible to make the bucket publicly accessible using fine-grained?

I'm using Terraform to create the bucket this way, and by changing bucket_policy_only value to false it made it fine-grande, but I cannot access images publicly anymore.

Do I need to change anything else on the bucket level to make it accessible publicly for everyone to read with fine-grained? 🤔 (i.e.: adding new role or something?)

resource "google_storage_bucket" "bucket-public" {
  name     = var.bucket_name_public
  location = var.bucket_location

  force_destroy = false

  bucket_policy_only = false

  website {
    main_page_suffix = "index.html"
    not_found_page   = "404.jpg"
  }
  cors {
    origin              = ["*"] // This allows allows everyone to fetch for test
    method          = ["GET", "HEAD", "PUT", "POST", "DELETE"]
    response_header = ["*"]
    max_age_seconds = 3600
  }
}

@prazian
Copy link

prazian commented Mar 17, 2020

Sorry my stupid mistake. 😄
I forgot to add 'visibility' => 'public' in the filesystem config file

@wmather
Copy link

wmather commented Apr 20, 2020

@tao I believe this is the problem https://github.com/Superbalist/flysystem-google-cloud-storage/blob/f3ec295003c52502a33ef8b97ed1b184ffb89871/src/GoogleStorageAdapter.php#L148
as per this change: https://github.com/googleapis/google-cloud-php/pull/2541/files

$options['predefinedAcl'] should not exist if the bucket has uniform access control. There is no way to prevent his being passed by this package's parent.

@tao
Copy link

tao commented Apr 22, 2020

Sorry, I can't confirm if this fixes the issue anymore. I find google cloud quite frustrating to use so I switched back to AWS.

@tthiagogaia
Copy link

Sorry for the comment spam, but my issue was solved by changing the bucket access controls to 'fine grained' verses 'uniform'.
image

Hope this helps (although brings up the issue of buckets that use uniform permissions..)

Solved for me, thanks!

@ultrono
Copy link

ultrono commented Nov 3, 2021

For new or buckets less than 90 days old the solution from @LorenzoSapora works. For existing buckets older than 90 days this isn't allowed by Google. Google themselves suggest creating a new bucket.

From what I can see this is the only solutipon until Superbalist/flysystem-google-cloud-storage#114 is merged.

@arifw3
Copy link

arifw3 commented Aug 10, 2023

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants