0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Googleで管理されているサービスアカウントについて

Last updated at Posted at 2025-04-07

はじめに

どうも、@to-fmakです。Google Cloudの一部のサービスでは、サービス利用時にGoogleが管理するデフォルトのサービスアカウントが作成されることがあります。これらのサービスアカウントは、一般的に「サービス エージェント」とも呼ばれ、必要な権限を付与することで利用することができます。今回は、Googleが管理するサービスアカウント(サービス エージェント)の確認方法と、権限を付与する方法について簡単に共有したいと思います。

管理コンソールの表示について

IAMの管理コンソールでは、ユーザが作ったもの以外はデフォルトでは非表示になっています。表示するには、「Google 提供のロール付与を含める」にチェックを入れる必要があります。

Screenshot 2025-04-03 at 13.54.53.png

また、CLIでサービスアカウントを含めたIAMポリシーを確認する場合、以下のコマンドが使用できます。

gcloud projects get-iam-policy <PROJECT_ID>

権限付与について

管理コンソールから権限を付与する場合、以下の手順で設定できます。

  • IAM画面にアクセスし、「アクセスを許可」をクリック
  • 「プリンシパルの追加」で対象のサービスアカウントを入力
  • 適切なロールを選択し、「保存」をクリック

または、既存のサービスアカウントの権限を変更する場合は、対象プリンシパルの横にある「編集」アイコンをクリックして、ロールを追加・削除できます。

CLIで権限を付与・削除する場合、以下のコマンドを使用します。

# ロールの追加
gcloud projects add-iam-policy-binding <PROJECT_ID> --member='serviceAccount:xxxxx@xxxxx.iam.gserviceaccount.com' --role=<ROLE_NAME>

# ロールの削除
gcloud projects remove-iam-policy-binding <PROJECT_ID> --member='serviceAccount:xxxxx@xxxxx.iam.gserviceaccount.com' --role=<ROLE_NAME>

また、Terraformでロール割り当てを行うことも可能です。以下は一例です。

resource "google_project_iam_member" "example" {
  project = "<PROJECT_ID>"
  member  = "serviceAccount:xxxxx@xxxxx.iam.gserviceaccount.com"
  role    = "<ROLE_NAME>"
}

参考URL

エンジニア募集

Gakken LEAP では教育をアップデートしていきたいエンジニアを絶賛大募集しています!!
ぜひお気軽にカジュアル面談へお越しください!!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?