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?

Cloud Pub/Sub→Splunkの連携をpull型で行う時に、特定のSubscriptionだけを読み取る権限を与える方法

Posted at

Cloud Pub/SubからSplunkにデータを連携するとき、基本的にはDataflowを使ったpush型の連携方法が推奨されていますが、データ量が少ない場合などはpull型のほうが簡単に構築できます。

具体的な手順は以下に書かれていますが、この方法ですとSplunkが全てのPub/Sub Subscriptionからデータを読み出すことができてしまいます。
それは権限が過剰で特定のSubscriptionだけにしたい場合の権限設定方法を紹介します。

以下のterraformのような設定をすると、特定のSubscriptionだけの読み出し権限を付与できます。

# Splunkに登録するService Account
resource "google_service_account" "splunk-integration" {
  account_id   = "splunk-integration"
  display_name = "Service Account for Splunk Integration"
}

# Splunkに連携したいSubscription
resource "google_pubsub_subscription" "splunk-integration" {
  name  = "splunk-integration-subscription"
  topic = <topic ID>
}

resource "google_pubsub_subscription_iam_member" "splunk-integration" {
  subscription = google_pubsub_subscription.splunk-integration.name
  role         = "roles/pubsub.subscriber"
  member       = google_service_account.splunk-integration.member
}

resource "google_project_iam_member" "splunk-integration" {
  project = <Project ID>
  role    = "roles/pubsub.viewer"
  member  = google_service_account.splunk-integration.member
}

pubsub/subscriber ロールはSubscriptionレベルで付与している一方で、 pubsub/viewer ロールはプロジェクトレベルで付与していることに注意が必要です。
一見すると後者もSubscriptionレベルで十分な気もしますが、そうしてしまうと projects.get パーミッションが付与されないため、Splunkがエラーを出してしまいます。

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?