Mengaktifkan notifikasi temuan untuk Pub/Sub

Halaman ini menjelaskan cara mengaktifkan notifikasi Security Command Center API.

Notifikasi mengirim temuan dan pembaruan temuan ke topik Pub/Sub dalam hitungan menit. Notifikasi Security Command Center API menyertakan semua informasi temuan yang ditampilkan oleh Security Command Center di konsolGoogle Cloud .

Anda dapat menghubungkan notifikasi Security Command Center di Pub/Sub langsung ke tindakan fungsi Cloud Run. Misalnya, fungsi yang dapat membantu respons, pengayaan, dan perbaikan, lihat repositori open source Security Command Center untuk kode fungsi Cloud Run. Repositori ini berisi solusi untuk membantu Anda mengambil tindakan otomatis pada penemuan keamanan.

Atau, Anda dapat mengekspor temuan ke BigQuery, atau menyiapkan Ekspor Berkelanjutan untuk Pub/Sub di konsol Google Cloud .

Sebelum memulai

  1. Untuk mendapatkan izin yang Anda perlukan untuk menyiapkan dan mengonfigurasi notifikasi Security Command Center API, minta administrator untuk memberi Anda peran IAM berikut:

    • Security Center Admin (roles/securitycenter.admin) di organisasi atau project tempat Security Command Center diaktifkan
    • Project IAM Admin (roles/resourcemanager.projectIamAdmin) pada project tempat Anda akan membuat topik Pub/Sub

    Untuk mengetahui informasi selengkapnya tentang cara memberikan peran, lihat Mengelola akses ke project, folder, dan organisasi.

    Anda mungkin juga bisa mendapatkan izin yang diperlukan melalui peran khusus atau peran bawaan lainnya.

  2. Enable the Security Command Center API:

    gcloud services enable securitycenter.googleapis.com

Notifikasi dan residensi data

Jika aset data diaktifkan untuk Security Command Center, konfigurasi yang menentukan ekspor berkelanjutan ke resource Pub/Sub—notificationConfig—tunduk pada kontrol aset data dan disimpan di lokasi Security Command Center Anda.

Untuk mengekspor temuan di lokasi Security Command Center ke Pub/Sub, Anda harus mengonfigurasi ekspor berkelanjutan di lokasi Security Command Center yang sama dengan temuan.

Karena filter yang digunakan dalam ekspor berkelanjutan dapat berisi data yang tunduk pada kontrol tempat tinggal, pastikan Anda menentukan lokasi yang benar sebelum membuatnya. Security Command Center tidak membatasi lokasi tempat Anda membuat ekspor.

Ekspor berkelanjutan hanya disimpan di lokasi tempat ekspor dibuat dan tidak dapat dilihat atau diedit di lokasi lain.

Setelah membuat ekspor berkelanjutan, Anda tidak dapat mengubah lokasinya. Untuk mengubah lokasi, Anda harus menghapus ekspor berkelanjutan dan membuatnya ulang di lokasi baru.

Untuk mengambil ekspor berkelanjutan menggunakan panggilan API, Anda harus menentukan lokasi dalam nama resource lengkap notificationConfig. Contoh:

GET https://securitycenter.googleapis.com/v2/organizations/123/locations/eu/notificationConfigs/my-pubsub-export-01

Demikian pula, untuk mengambil ekspor berkelanjutan menggunakan gcloud CLI, Anda harus menentukan lokasi menggunakan flag --location. Contoh:

gcloud scc notifications describe myContinuousExport --organization=123 \
    --location=us

Menyiapkan topik Pub/Sub

Dalam tugas ini, Anda akan membuat dan berlangganan topik Pub/Sub yang ingin Anda kirimi notifikasi.

Langkah 1: Siapkan Pub/Sub

Untuk menyiapkan dan berlangganan topik Pub/Sub, lakukan hal berikut:

  1. Buka Google Cloud konsol.

    Buka Google Cloud konsol

  2. Pilih project tempat Anda mengaktifkan Security Command Center API.

  3. Klik Aktifkan Cloud Shell.

  4. Opsional: Untuk membuat topik Pub/Sub baru, jalankan perintah berikut:

    gcloud pubsub topics create TOPIC_ID
    

    Ganti TOPIC_ID dengan nama topik.

  5. Buat langganan ke topik:

    gcloud pubsub subscriptions create SUBSCRIPTION_ID --topic=TOPIC_ID
    

    Ganti kode berikut:

    • SUBSCRIPTION_ID: ID langganan
    • TOPIC_ID: ID topik

Untuk mempelajari lebih lanjut cara menyiapkan Pub/Sub, lihat Mengelola topik dan langganan.

Langkah 2: Berikan peran pada topik Pub/Sub

Untuk membuat NotificationConfig, Anda memerlukan peran Admin Pub/Sub (roles/pubsub.admin) di topik Pub/Sub tempat Anda membuat langganan.

Untuk memberikan peran ini, lakukan hal berikut:

  1. Buka Google Cloud konsol.

    Buka Google Cloud konsol

  2. Pilih project tempat Anda mengaktifkan Security Command Center API.

  3. Klik Aktifkan Cloud Shell.

  4. Berikan peran yang diperlukan ke Akun Google Anda di topik Pub/Sub:

    gcloud pubsub topics add-iam-policy-binding \
        projects/PUBSUB_PROJECT/topics/TOPIC_ID \
        --member="user:GOOGLE_ACCOUNT" \
        --role="roles/pubsub.admin"
    

    Ganti kode berikut:

    • PUBSUB_PROJECT: Google Cloud project yang berisi topik Pub/Sub Anda
    • TOPIC_ID: ID topik
    • GOOGLE_ACCOUNT: alamat email untuk Akun Google Anda

Membuat NotificationConfig

Sebelum membuat NotificationConfig, perhatikan bahwa setiap organisasi dapat memiliki jumlah file NotificationConfig yang terbatas. Untuk mengetahui informasi selengkapnya, lihat Kuota dan batas.

NotificationConfig menyertakan kolom filter yang membatasi notifikasi ke peristiwa yang berguna. Kolom ini menerima semua filter yang tersedia di metode findings.list Security Command Center API.

Saat membuat NotificationConfig, Anda menentukan induk untuk NotificationConfig dari hierarki resource Google Cloud , baik organisasi, folder, maupun project. Jika perlu mengambil, memperbarui, atau menghapus NotificationConfig nanti, Anda harus menyertakan ID numerik organisasi, folder, atau project induk saat mereferensikannya.

Di konsol Google Cloud , beberapa resource NotificationConfig mungkin memiliki label Lama, yang menunjukkan bahwa resource tersebut dibuat dengan Security Command Center API v1. Anda dapat mengelola resource NotificationConfig ini dengan konsol Google Cloud ; gcloud CLI; Security Command Center API v1; atau library klien v1 untuk Security Command Center.

Untuk mengelola resource NotificationConfig ini dengan gcloud CLI, Anda tidak boleh menentukan lokasi saat menjalankan perintah gcloud CLI.

Untuk membuat NotificationConfig menggunakan bahasa atau platform pilihan Anda:

gcloud

gcloud scc notifications create NOTIFICATION_NAME \
  --PARENT=PARENT_ID \
  --location=LOCATION
  --description="NOTIFICATION_DESCRIPTION" \
  --pubsub-topic=PUBSUB_TOPIC \
  --filter="FILTER"

Ganti kode berikut:

  • NOTIFICATION_NAME: nama notifikasi. Harus antara 1 hingga 128 karakter dan hanya boleh berisi karakter alfanumerik, garis bawah, atau tanda hubung.
  • PARENT: cakupan dalam hierarki resource tempat notifikasi berlaku, organization, folder, atau project.
  • PARENT_ID: ID organisasi induk, folder, atau project, yang ditentukan dalam format organizations/123, folders/456, atau projects/789.
  • LOCATION: jika aset data diaktifkan, lokasi Security Command Center tempat untuk ; jika aset data tidak diaktifkan, gunakan nilai global.
  • NOTIFICATION_DESCRIPTION: deskripsi notifikasi yang tidak lebih dari 1.024 karakter.
  • PUBSUB_TOPIC: Topik Pub/Sub yang akan menerima notifikasi. Formatnya adalah projects/PROJECT_ID/topics/TOPIC.
  • FILTER: ekspresi yang Anda tentukan untuk memilih temuan yang dikirim ke Pub/Sub. Contoh, state=\"ACTIVE\".

Terraform

Buat NotificationConfig untuk organisasi:

resource "google_pubsub_topic" "scc_v2_organization_notification_config" {
  name = "my-topic"
}

resource "google_scc_v2_organization_notification_config" "custom_organization_notification_config" {
  config_id    = "my-config"
  organization = "123456789"
  location     = "global"
  description  = "My custom Cloud Security Command Center Finding Organization Notification Configuration"
  pubsub_topic = google_pubsub_topic.scc_v2_organization_notification_config.id

  streaming_config {
    filter = "category = \"OPEN_FIREWALL\" AND state = \"ACTIVE\""
  }
}

Buat NotificationConfig untuk folder:

resource "google_folder" "folder" {
  parent       = "organizations/123456789"
  display_name = "folder-name"
}

resource "google_pubsub_topic" "scc_v2_folder_notification_config" {
  name = "my-topic"
}

resource "google_scc_v2_folder_notification_config" "custom_notification_config" {
  config_id    = "my-config"
  folder       = google_folder.folder.folder_id
  location     = "global"
  description  = "My custom Cloud Security Command Center Finding Notification Configuration"
  pubsub_topic =  google_pubsub_topic.scc_v2_folder_notification_config.id

  streaming_config {
    filter = "category = \"OPEN_FIREWALL\" AND state = \"ACTIVE\""
  }
}

Buat NotificationConfig untuk project:

resource "google_pubsub_topic" "scc_v2_project_notification" {
  name = "my-topic"
}

resource "google_scc_v2_project_notification_config" "custom_notification_config" {
  config_id    = "my-config"
  project      = "my-project-name"
  location     = "global"
  description  = "My custom Cloud Security Command Center Finding Notification Configuration"
  pubsub_topic =  google_pubsub_topic.scc_v2_project_notification.id

  streaming_config {
    filter = "category = \"OPEN_FIREWALL\" AND state = \"ACTIVE\""
  }
}

Go

import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv2"
	"cloud.google.com/go/securitycenter/apiv2/securitycenterpb"
)

func createNotificationConfig(w io.Writer, orgID string, pubsubTopic string, notificationConfigID string) error {
	// orgID := "your-org-id"
	// pubsubTopic := "projects/{your-project}/topics/{your-topic}"
	// notificationConfigID := "your-config-id"

	ctx := context.Background()
	client, err := securitycenter.NewClient(ctx)

	if err != nil {
		return fmt.Errorf("securitycenter.NewClient: %w", err)
	}
	defer client.Close()

	req := &securitycenterpb.CreateNotificationConfigRequest{
		// Parent must be in one of the following formats:
		//		"organizations/{orgId}/locations/global"
		//		"projects/{projectId}/locations/global"
		//		"folders/{folderId}/locations/global"
		Parent:   fmt.Sprintf("organizations/%s/locations/global", orgID),
		ConfigId: notificationConfigID,
		NotificationConfig: &securitycenterpb.NotificationConfig{
			Description: "Go sample config",
			PubsubTopic: pubsubTopic,
			NotifyConfig: &securitycenterpb.NotificationConfig_StreamingConfig_{
				StreamingConfig: &securitycenterpb.NotificationConfig_StreamingConfig{
					Filter: `state = "ACTIVE"`,
				},
			},
		},
	}

	notificationConfig, err := client.CreateNotificationConfig(ctx, req)
	if err != nil {
		return fmt.Errorf("Failed to create notification config: %w", err)
	}
	fmt.Fprintln(w, "New NotificationConfig created: ", notificationConfig)

	return nil
}

Java


package vtwo.notifications;

import com.google.cloud.securitycenter.v2.LocationName;
import com.google.cloud.securitycenter.v2.NotificationConfig;
import com.google.cloud.securitycenter.v2.SecurityCenterClient;
import java.io.IOException;

public class CreateNotification {

  public static void main(String[] args) throws IOException {
    // parentId: must be in one of the following formats:
    //    "organizations/{organization_id}"
    //    "projects/{project_id}"
    //    "folders/{folder_id}"
    String parentId = "{parent-id}";
    String topicName = "{your-topic}";
    String notificationConfigId = "{your-notification-id}";
    // Specify the location of the notification config.
    String location = "global";

    createNotificationConfig(parentId, location, topicName, notificationConfigId);
  }

  // Crete a notification config.
  // Ensure the ServiceAccount has the "pubsub.topics.setIamPolicy" permission on the new topic.
  public static NotificationConfig createNotificationConfig(
      String parentId, String location, String topicName, String notificationConfigId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {

      String pubsubTopic = String.format("projects/%s/topics/%s", parentId, topicName);

      NotificationConfig notificationConfig = NotificationConfig.newBuilder()
          .setDescription("Java notification config")
          .setPubsubTopic(pubsubTopic)
          .setStreamingConfig(
              NotificationConfig.StreamingConfig.newBuilder().setFilter("state = \"ACTIVE\"")
                  .build())
          .build();

      NotificationConfig response = client.createNotificationConfig(
          LocationName.of(parentId, location), notificationConfig, notificationConfigId);

      System.out.printf("Notification config was created: %s%n", response);
      return response;
    }
  }
}

Node.js

// npm install '@google-cloud/security-center'
const {SecurityCenterClient} = require('@google-cloud/security-center').v2;
const uuidv1 = require('uuid').v1;

const client = new SecurityCenterClient();
/*
 *  Required. Resource name of the new notification config's parent. Its format
 *  is "organizations/[organization_id]/locations/[location_id]",
 *  "folders/[folder_id]/locations/[location_id]", or
 *  "projects/[project_id]/locations/[location_id]".
 */
const parent = `projects/${projectId}/locations/${location}`;

/**
 *  Required.
 *  Unique identifier provided by the client within the parent scope.
 *  It must be between 1 and 128 characters and contain alphanumeric
 *  characters, underscores, or hyphens only.
 */
const configId = 'notif-config-test-node-create-' + uuidv1();

// pubsubTopic = "projects/{your-project}/topics/{your-topic}";
const pubsubTopic = `projects/${projectId}/topics/${topicName}`;

/**
 *  Required. The notification config being created. The name and the service
 *  account will be ignored as they are both output only fields on this
 *  resource.
 */
const notificationConfig = {
  description: 'Sample config for node v2',
  pubsubTopic: pubsubTopic,
  streamingConfig: {filter: 'state = "ACTIVE"'},
};

// Build the request.
const createNotificationRequest = {
  parent: parent,
  configId: configId,
  notificationConfig: notificationConfig,
};

async function createNotificationConfig() {
  const [response] = await client.createNotificationConfig(
    createNotificationRequest
  );
  console.log('Notification configuration creation successful: %j', response);
}

await createNotificationConfig();

Python

def create_notification_config(
    parent_id, location_id, pubsub_topic, notification_config_id
) -> NotificationConfig:
    """
    This method is used to create the Notification Config.
    Args:
        parent_id: must be in one of the following formats:
            "organizations/{organization_id}"
            "projects/{project_id}"
            "folders/{folder_id}"
        location_id: "global"
        pubsub_topic: "projects/{your-project-id}/topics/{your-topic-id}"
        notification_config_id: "your-config-id"


    Ensure this ServiceAccount has the "pubsub.topics.setIamPolicy" permission on the new topic.
    """
    from google.cloud import securitycenter_v2 as securitycenter_v2

    client = securitycenter_v2.SecurityCenterClient()
    parent_id = parent_id + "/locations/" + location_id
    response = client.create_notification_config(
        request={
            "parent": parent_id,
            "config_id": notification_config_id,
            "notification_config": {
                "description": "Notification for active findings",
                "pubsub_topic": pubsub_topic,
                "streaming_config": {"filter": 'state = "ACTIVE"'},
            },
        }
    )
    print(f"create notification config response:{response}")
    return response

Notifikasi kini dipublikasikan ke topik Pub/Sub yang Anda tentukan.

Untuk memublikasikan notifikasi, akun layanan akan dibuat untuk Anda dalam bentuk service-org-ORGANIZATION_ID@gcp-sa-scc-notification.iam.gserviceaccount.com. Akun layanan ini dibuat saat Anda membuat NotificationConfig pertama dan secara otomatis diberi peran securitycenter.notificationServiceAgent pada kebijakan IAM untuk PUBSUB_TOPIC saat membuat konfigurasi notifikasi. Peran akun layanan ini diperlukan agar notifikasi dapat berfungsi.

Memberi akses perimeter di Kontrol Layanan VPC

Jika menggunakan Kontrol Layanan VPC dan topik Pub/Sub Anda adalah bagian dari project di dalam perimeter layanan, Anda harus memberikan akses ke project untuk membuat notifikasi.

Untuk memberikan akses ke project, buat aturan masuk dan keluar untuk akun utama dan project yang digunakan untuk membuat notifikasi. Aturan ini mengizinkan akses ke resource yang dilindungi dan memungkinkan Pub/Sub memverifikasi bahwa pengguna memiliki izin setIamPolicy di topik Pub/Sub.

Sebelum membuat NotificationConfig

Sebelum menyelesaikan langkah-langkah dalam Membuat NotificationConfig, selesaikan langkah-langkah berikut.

Konsol

  1. Di Google Cloud konsol, buka halaman VPC Service Controls.

    Buka Kontrol Layanan VPC

  2. Pilih organisasi atau project Anda.
  3. Jika Anda memilih organisasi, klik Pilih kebijakan akses, lalu pilih kebijakan akses yang terkait dengan perimeter yang ingin Anda perbarui.
  4. Klik nama perimeter yang ingin diperbarui.

    Untuk menemukan perimeter layanan yang perlu diubah, Anda dapat memeriksa log untuk menemukan entri yang menunjukkan pelanggaran RESOURCES_NOT_IN_SAME_SERVICE_PERIMETER. Dalam entri tersebut, periksa kolom servicePerimeterName:

    accessPolicies/ACCESS_POLICY_ID/servicePerimeters/SERVICE_PERIMETER_NAME
  5. Klik Edit perimeter.
  6. Klik Kebijakan traffic keluar.
  7. Klik Tambahkan aturan traffic keluar.
  8. Di bagian FROM, tetapkan detail berikut:

    1. Untuk Identity, pilih Select identities & groups.
    2. Klik Tambahkan identitas
    3. Masukkan alamat email akun utama yang digunakan untuk memanggil Security Command Center API.

    4. Pilih akun utama atau tekan ENTER, lalu klik Tambahkan identitas.
  9. Di bagian KE, tetapkan detail berikut:

    1. Untuk Project, pilih All projects.
    2. Untuk Operasi atau peran IAM, pilih Pilih operasi.
    3. Klik Tambahkan operasi, lalu tambahkan operasi berikut:

      • Tambahkan layanan pubsub.googleapis.com.
        1. Klik Semua metode.
        2. Klik Tambahkan semua metode.
  10. Klik Kebijakan ingress.
  11. Klik Tambahkan aturan masuk.
  12. Di bagian FROM, tetapkan detail berikut:

    1. Untuk Identity, pilih Select identities & groups.
    2. Klik Tambahkan identitas
    3. Masukkan alamat email akun utama yang digunakan untuk memanggil Security Command Center API.

    4. Pilih akun utama atau tekan ENTER, lalu klik Tambahkan identitas.
    5. Untuk Sumber, pilih Semua sumber
  13. Di bagian KE, tetapkan detail berikut:

    1. Untuk Project, pilih Select projects.
    2. Klik Add projects, lalu tambahkan project yang berisi topik Pub/Sub.
    3. Untuk Operasi atau peran IAM, pilih Pilih operasi.
    4. Klik Tambahkan operasi, lalu tambahkan operasi berikut:

      • Tambahkan layanan pubsub.googleapis.com.
        1. Klik Semua metode.
        2. Klik Tambahkan semua metode.
  14. Klik Simpan.

gcloud

  1. Jika project kuota belum ditetapkan, tetapkan project tersebut. Pilih project yang mengaktifkan Access Context Manager API.

    gcloud config set billing/quota_project QUOTA_PROJECT_ID

    Ganti QUOTA_PROJECT_ID dengan ID project yang ingin Anda gunakan untuk penagihan dan kuota.

  2. Buat file bernama egress-rule.yaml dengan konten berikut:

    - egressFrom:
        identities:
        - PRINCIPAL_ADDRESS
      egressTo:
        operations:
        - serviceName: pubsub.googleapis.com
          methodSelectors:
          - method: '*'
        resources:
        - '*'

    Ganti PRINCIPAL_ADDRESS dengan alamat akun utama yang digunakan untuk memanggil Security Command Center API.

  3. Buat file bernama ingress-rule.yaml dengan konten berikut:

    - ingressFrom:
        identities:
        - PRINCIPAL_ADDRESS
        sources:
        - accessLevel: '*'
      ingressTo:
        operations:
        - serviceName: pubsub.googleapis.com
          methodSelectors:
          - method: '*'
        resources:
        - '*'

    Ganti PRINCIPAL_ADDRESS dengan alamat akun utama yang digunakan untuk memanggil Security Command Center API.

  4. Tambahkan aturan traffic keluar ke perimeter:

    gcloud access-context-manager perimeters update PERIMETER_NAME \
        --set-egress-policies=egress-rule.yaml

    Ganti kode berikut:

    • PERIMETER_NAME: nama perimeter. Misalnya, accessPolicies/1234567890/servicePerimeters/example_perimeter.

      Untuk menemukan perimeter layanan yang perlu diubah, Anda dapat memeriksa log untuk menemukan entri yang menunjukkan pelanggaran RESOURCES_NOT_IN_SAME_SERVICE_PERIMETER. Dalam entri tersebut, periksa kolom servicePerimeterName:

      accessPolicies/ACCESS_POLICY_ID/servicePerimeters/SERVICE_PERIMETER_NAME
  5. Tambahkan aturan traffic masuk ke perimeter:

    gcloud access-context-manager perimeters update PERIMETER_NAME \
        --set-ingress-policies=ingress-rule.yaml

    Ganti kode berikut:

    • PERIMETER_NAME: nama perimeter. Misalnya, accessPolicies/1234567890/servicePerimeters/example_perimeter.

      Untuk menemukan perimeter layanan yang perlu diubah, Anda dapat memeriksa log untuk menemukan entri yang menunjukkan pelanggaran RESOURCES_NOT_IN_SAME_SERVICE_PERIMETER. Dalam entri tersebut, periksa kolom servicePerimeterName:

      accessPolicies/ACCESS_POLICY_ID/servicePerimeters/SERVICE_PERIMETER_NAME

Lihat Aturan traffic masuk dan keluar untuk mengetahui informasi selengkapnya.

Membuat aturan ingress untuk NotificationConfig

Untuk membuat aturan masuk bagi NotificationConfig, selesaikan petunjuk di Membuat NotificationConfig, lalu selesaikan langkah-langkah berikut.

Konsol

  1. Buka kembali perimeter layanan dari bagian sebelumnya.

    Buka Kontrol Layanan VPC

  2. Klik Kebijakan ingress.
  3. Klik Tambahkan aturan masuk.
  4. Di bagian FROM, tetapkan detail berikut:

    1. Untuk Identity, pilih Select identities & groups.
    2. Klik Tambahkan identitas
    3. Masukkan alamat email agen layanan NotificationConfig. Alamat agen layanan memiliki format berikut:

      service-org-ORGANIZATION_ID@gcp-sa-scc-notification.iam.gserviceaccount.com

      Ganti ORGANIZATION_ID dengan ID organisasi Anda.

    4. Pilih agen layanan atau tekan ENTER, lalu klik Tambahkan identitas.
    5. Untuk Sumber, pilih Semua sumber
  5. Di bagian KE, tetapkan detail berikut:

    1. Untuk Project, pilih Select projects.
    2. Klik Add projects, lalu tambahkan project yang berisi topik Pub/Sub.
    3. Untuk Operasi atau peran IAM, pilih Pilih operasi.
    4. Klik Tambahkan operasi, lalu tambahkan operasi berikut:

      • Tambahkan layanan pubsub.googleapis.com.
        1. Klik Semua metode.
        2. Klik Tambahkan semua metode.
  6. Klik Simpan.

gcloud

  1. Jika project kuota belum ditetapkan, tetapkan project tersebut. Pilih project yang mengaktifkan Access Context Manager API.

    gcloud config set billing/quota_project QUOTA_PROJECT_ID

    Ganti QUOTA_PROJECT_ID dengan ID project yang ingin Anda gunakan untuk penagihan dan kuota.

  2. Buat file bernama ingress-rule.yaml dengan konten berikut:

    - ingressFrom:
        identities:
        - serviceAccount:service-org-ORGANIZATION_ID@gcp-sa-scc-notification.iam.gserviceaccount.com
        sources:
        - accessLevel: '*'
      ingressTo:
        operations:
        - serviceName: pubsub.googleapis.com
          methodSelectors:
          - method: '*'
        resources:
        - '*'

    Ganti ORGANIZATION_ID dengan ID organisasi Anda.

  3. Tambahkan aturan traffic masuk ke perimeter:

    gcloud access-context-manager perimeters update PERIMETER_NAME \
        --set-ingress-policies=ingress-rule.yaml

    Ganti kode berikut:

    • PERIMETER_NAME: nama perimeter. Misalnya, accessPolicies/1234567890/servicePerimeters/example_perimeter.

      Untuk menemukan perimeter layanan yang perlu diubah, Anda dapat memeriksa log untuk menemukan entri yang menunjukkan pelanggaran RESOURCES_NOT_IN_SAME_SERVICE_PERIMETER. Dalam entri tersebut, periksa kolom servicePerimeterName:

      accessPolicies/ACCESS_POLICY_ID/servicePerimeters/SERVICE_PERIMETER_NAME

Lihat Aturan traffic masuk dan keluar untuk mengetahui informasi selengkapnya.

Project, pengguna, dan akun layanan yang dipilih kini dapat mengakses resource yang dilindungi dan membuat notifikasi.

Jika Anda telah mengikuti semua langkah dalam panduan ini, dan notifikasi berfungsi dengan benar, sekarang Anda dapat menghapus hal berikut:

  • Aturan masuk untuk akun utama
  • Aturan traffic keluar untuk akun utama

Aturan tersebut hanya diperlukan untuk mengonfigurasi NotificationConfig. Namun, agar notifikasi terus berfungsi, Anda harus mempertahankan aturan masuk untuk NotificationConfig, yang memungkinkannya memublikasikan notifikasi ke topik Pub/Sub di balik perimeter layanan.

Langkah berikutnya