2022/09/23 の夜、個人で運営しているサイトの画像がすべて表示されなくなった。
エラーの内容を見てみると、
{ "error": { "code": 412, "message": "A required service account is missing necessary permissions. Please resolve by visiting the Storage page of the Firebase Console and re-linking your Firebase bucket or see this FAQ for more info: https://firebase.google.com/support/faq#storage-accounts" }}
というような内容だった。
急いでエラーメッセージをもとに検索してみると、
firebaseのgithub上で、まさに09/23付けでIssueが立ち上がっていた。
その内容をもとにどのような修正を行ったか、書き記しておく。
①Google Cloud のIAMを開く
https://console.cloud.google.com/
②画面上部のADDから、新しいプリンシパルを作成する。
「新しいプリンシパル」:
service-[firebaseのプロジェクト番号]@gcp-sa-firebasestorage.iam.gserviceaccount.com
「ロール」
Cloud Storage for Firebase サービス エージェント
③保存して、確認する。(反映に数分時間がかかる?)
以上の設定で再びStorageにアクセスできるようになりました。
※firebaseのプロジェクト番号は、firebaseプロジェクトの「プロジェクトの設定」画面に書いてあります。
主に参考にしたもの
・上記のIssue:
https://github.com/firebase/flutterfire/issues/9588
・Firebaseのcloud-storageのサービスアカウントについて
https://firebase.google.com/support/faq#storage-buckets
突然こういう事態が発生するのかと驚きました。
取り急ぎ以上です!