ThomasGrossmann / BI1

MIT License
0 stars 0 forks source link

Issue with bucket interaction #1

Closed ThomasGrossmann closed 9 months ago

ThomasGrossmann commented 9 months ago

Depuis le CLI gcloud

En entrant les commandes

gcloud storage buckets describe gs://php.gogle.cld.education OU gcloud storage du gs://php.gogle.cld.education --summarize OU gcloud storage cp /Users/thomas/Desktop/Test.rtf gs://php.gogle.cld.education

Reçoit le message d'erreur

ERROR: User [bi-thomas@es-bi-370207.iam.gserviceaccount.com] does not have permission to access b instance [php.gogle.cld.education] (or it may not exist): [droits correspondant à la commande]

image

Depuis le code

En essayant de voir les infos du bucket

use Google\Cloud\Storage\StorageClient;

$env = parse_ini_file('.env');
$storage = new StorageClient([
    'keyFilePath' => $env['CREDENTIALS_PATH'],
]);

$bucket = $storage->bucket('php.gogle.cld.education');
$info = $bucket->info();

Reçoit le message d'erreur

{
   "error":{
      "code":403,
      "message":"bi-thomas@es-bi-370207.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":"bi-thomas@es-bi-370207.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"
         }
      ]
   }
}
NicolasGlassey commented 9 months ago

@ThomasGrossmann

Il y avait bien une erreur au niveau des droits sur votre bucket.

Ceci a été corrigé. Voici mes tests (après avoir généré une clé d'authentification pour le même utilisateur de service que vous)

[INPUT]
gcloud storage buckets describe gs://php.gogle.cld.education

[OUTPUT]
creation_time: 2023-12-06T13:33:19+0000
default_storage_class: STANDARD
location: US
location_type: multi-region
metageneration: 6
name: php.gogle.cld.education
public_access_prevention: enforced
rpo: DEFAULT
storage_url: gs://php.gogle.cld.education/
uniform_bucket_level_access: true
update_time: 2023-12-12T16:27:58+0000
ThomasGrossmann commented 9 months ago

@NicolasGlassey

Je vous confirme que tout est bon maintenant pour moi ! Merci