Cloud Deployment Managerでプロビジョニングするとき、エラー表記で少しハマったところについてメモ。
Cloud Storageをプロビジョニングするとき以下のようなエラーが出ることがあります。
$ gcloud deployment-manager deployments create example --config vm.yaml The fingerprint of the deployment is YjuHda-HR8_aaaaaaaaaaa== Waiting for create [operation-1549936918163-581a8cf6e71ac-aaaaaaaa-3f20fe82]...failed. ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1549936918163-581a8cf6e71ac-aaaaaaaa-3f20fe82]: errors: - code: RESOURCE_ERROR location: /deployments/batch/resources/example message: '{"ResourceType":"gcp-types/cloudfunctions-v1:projects.locations.functions","ResourceErrorCode":"500","ResourceErrorMessage":"Failed to retrieve function source code"}' - code: RESOURCE_ERROR location: /deployments/batch/resources/image message: '{"ResourceType":"gcp-types/storage-v1:buckets","ResourceErrorCode":"403","ResourceErrorMessage":{"code":403,"errors":[{"domain":"global","message":"example@cloudservices.gserviceaccount.com does not have storage.buckets.get access to image.","reason":"forbidden"}],"message":"example@cloudservices.gserviceaccount.com does not have storage.buckets.get access to image.","statusMessage":"Forbidden","requestPath":"https://www.googleapis.com/storage/v1/b/image","httpMethod":"GET","suggestion":"Consider granting permissions to example@cloudservices.gserviceaccount.com"}}'
does not have storage.buckets.get access to image.","statusMessage":"Forbidden" や Consider granting permissions to example@cloudservices.gserviceaccount.com と言われるので、普通に考えるとパーミッションかなと思いサービスアカウントの権限を確認しますが十分な権限が付与されていました。
結論としては、作成しようとしているバケットの名前が他のユーザーのバケット名と被っているためです。バケットの名前は全てのユーザーでユニークな名前にする必要があります。
当たり前ですが作成しようとしているバケットが自分のものではない場合、そのバケットにアクセスする権限はありません。なので、does not have storage.buckets.get access to image のような表記になっています。