# Google Pub/Sub 대상

## 개요

대상은 룰, 정책, 시스템 상태 알러트 및 룰 오류로부터 알러트를 수신하는 통합입니다. Panther는 다음을 구성하는 것을 지원합니다 [Google Pub/Sub](https://cloud.google.com/pubsub?hl=en) 주제(topic)를 알러트를 수신할 대상(destination)으로 사용합니다.

## Panther에서 Google Pub/Sub 알러트 대상 설정하는 방법

### **1단계: 생성** 필수 Google Cloud Platform(GCP) 인프라

Panther가 알러트를 Pub/Sub 주제로 메시지로 게시하도록 하려면, 주제(새로 만들거나 기존 것)와 자격 증명 파일이 필요합니다. Panther는 Google Cloud [Workload Identity Federation](https://cloud.google.com/iam/docs/workload-identity-federation) 또는 [서비스 계정](https://cloud.google.com/iam/docs/service-account-overview).

{% tabs %}
{% tab title="서비스 계정 인증" %}

1. 이미 없다면, [Pub/Sub 주제를 생성하세요](https://cloud.google.com/pubsub/docs/create-topic#creating_a_topic) 알림용으로.
   * 다음을 사용하여 주제를 생성할 수 있습니다. `gcloud` CLI 도구를 사용하며, 명령 형식은 다음과 같습니다: `gcloud pubsub topics create $TOPIC_ID`
2. [IAM API 사용 설정](https://console.cloud.google.com/apis/library/iam.googleapis.com).
3. [새 Google Cloud 서비스 계정 생성](https://cloud.google.com/iam/docs/creating-managing-service-accounts). 계정을 생성하려면 `gcloud` CLI 도구를 사용하여 다음 명령 형식을 사용하세요:

   ```
   gcloud iam service-accounts create SA-NAME \
       --description="DESCRIPTION" \
       --display-name="DISPLAY_NAME"
   ```

   * 계정 이메일 주소를 반드시 기록해 두세요. Panther가 이 이메일을 사용하여 이 GCS 통합을 위해 생성된 인프라에 접근합니다.
4. 계정에 필요한 IAM 역할을 할당합니다.
   * 다음 권한은 Pub/Sub 구독과 주제가 있는 프로젝트에 필요합니다:

     <table data-header-hidden><thead><tr><th width="327.374982940047" align="center">필요한 권한</th><th width="294.15662026309724" align="center">역할</th><th width="208" align="center">조건</th></tr></thead><tbody><tr><td align="center"><code>pubsub.topics.publish</code></td><td align="center"><code>roles/pubsub.publisher</code></td><td align="center"><em>topic-name</em></td></tr></tbody></table>

     * **참고:** 특정 리소스에 대해 권한 조건 또는 IAM 정책을 설정할 수 있습니다. 이는 서비스 계정의 IAM 페이지(아래 예시 스크린샷에서 보이는 것처럼) 또는 특정 리소스의 페이지에서 수행할 수 있습니다.\
       ![There are two section titles, "Service account details" and "Grant this service account access to project"](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-75737a631f3bba75435c67c5dd2e964e25223b7e%2FScreenshot%202025-03-11%20at%2010.11.44.png?alt=media)
     * **참고:** 다음을 사용하여 권한을 생성할 수 있습니다. `gcloud` CLI 도구:
       * `gcloud projects add-iam-policy-binding $PROJECT_ID --member="serviceAccount:$SERVICE_ACCOUNT_EMAIL" --role="roles/pubsub.publisher"`
5. [서비스 계정용 JSON 키 파일을 생성하세요](https://cloud.google.com/iam/docs/creating-managing-service-account-keys) Panther에서 GCP 인프라에 인증하는 데 사용됩니다.
   * gcloud CLI 도구를 사용하여 JSON 키 파일을 만들려면 다음 명령 형식을 실행하세요:\
     `gcloud iam service-accounts keys create $KEYFILE_PATH --iam-account=$SERVICE_ACCOUNT_EMAIL`
   * 대안: 로컬 대신 GCP의 터미널에서 위 명령을 실행할 수 있습니다:
     1. 오른쪽 상단의 점 3개 아이콘 메뉴를 클릭한 다음 **다운로드**.
        * ![A dropdown menu is shown below a three-dots icon.](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-6940cc677e233faedec16959c99926def5e052be%2Fimage.png?alt=media)
     2. 찾아보기를 위해 폴더 아이콘을 클릭합니다.
     3. 키 파일로 이동하여 선택한 다음 **다운로드**.
        {% endtab %}

{% tab title="Workload Identity Federation 인증" %}

1. 이미 없다면, [Pub/Sub 주제를 생성하세요](https://cloud.google.com/pubsub/docs/admin#creating\\\\\\_a\\\\\\_topic) 알림용으로.
   * 다음을 사용하여 주제를 생성할 수 있습니다. `gcloud` CLI 도구를 사용하며, 명령 형식은 다음과 같습니다: `gcloud pubsub topics create $TOPIC_ID`
2. [IAM API 사용 설정](https://console.cloud.google.com/apis/library/iam.googleapis.com).
3. [AWS와 함께 Workload Identity Federation 구성](https://cloud.google.com/iam/docs/workload-identity-federation-with-other-clouds):
   1. 다음과 같이 [속성 매핑과 조건을 정의하는 동안](https://cloud.google.com/iam/docs/workload-identity-federation-with-other-clouds#mappings-and-conditions)다음 예시를 참고하세요:
      * 예제 [속성 매핑](https://cloud.google.com/iam/docs/workload-identity-federation#mapping):

<table><thead><tr><th width="250.04296875">Google</th><th width="437.63671875">AWS</th><th data-hidden></th></tr></thead><tbody><tr><td>google.subject</td><td>assertion.arn.extract('arn:aws:sts::{account_id}:')+":"+assertion.arn.extract('assumed-role/{role_and_session}').extract('/{session}')</td><td></td></tr><tr><td>attribute.account</td><td>assertion.account</td><td></td></tr></tbody></table>

* 예제 [속성 조건](https://cloud.google.com/iam/docs/workload-identity-federation#conditions): `attribute.account=="<PANTHER_AWS_ACCOUNT_ID>"`

{% hint style="warning" %}
다음의 값은 `google.subject` 속성 [127자를 초과할 수 없습니다](https://cloud.google.com/iam/docs/workload-identity-federation#mapping). 다음을 사용할 수 있습니다. [Common Expression Language(CEL) 표현식](https://cloud.google.com/iam/docs/workload-identity-federation#mapping) 을 사용하여 AWS에서 발급한 토큰의 속성을 변환하거나 결합할 수 있습니다. 위에서 제안한 표현식은 이를 고려한 것으로, arn을 Panther 엔터티를 고유하게 식별하는 값으로 "추출"하려는 시도입니다. AWS 속성에 대한 자세한 내용은 이 페이지의 "Example 2 - Called by user created with AssumeRole"를 확인하세요. [이 페이지](https://docs.aws.amazon.com/STS/latest/APIReference/API_GetCallerIdentity.html).
{% endhint %}

4. 다음 단계에서 [ID 풀에 공급자를 추가할 때](https://cloud.google.com/iam/docs/workload-identity-federation-with-other-clouds#aws)다음을 선택하세요 **AWS**.
5. 계정에 필요한 IAM 역할을 할당합니다.

* 다음 권한은 Pub/Sub 구독과 주제가 있는 프로젝트에 필요합니다:

  <table data-header-hidden><thead><tr><th width="327.374982940047" align="center">필요한 권한</th><th width="294.15662026309724" align="center">역할</th><th width="208" align="center">조건</th></tr></thead><tbody><tr><td align="center"><strong>필요한 권한</strong></td><td align="center"><strong>역할</strong></td><td align="center"><strong>범위</strong></td></tr><tr><td align="center"><code>pubsub.topics.publish</code></td><td align="center"><code>roles/pubsub.publisher</code></td><td align="center"><em>topic-name</em></td></tr></tbody></table>

  * **참고:** 특정 리소스에 대해 권한 조건 또는 IAM 정책을 설정할 수 있습니다. 이는 GCP의 IAM 섹션(아래 예시 스크린샷에서 보이는 것처럼) 또는 특정 리소스의 페이지에서 수행할 수 있습니다.\
    ![In the Google Cloud console, an "IAM" navigation item is circled. In a slide-out panel, sections titled, "Add principals" and "Assign roles" are circled.](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-d1fe568850252c3c65d8bea3c929d20422aedc2f%2FScreenshot%202025-03-11%20at%2010.33.30.png?alt=media)
  * **참고:** 다음을 사용하여 권한을 생성할 수 있습니다. `gcloud` CLI 도구, 여기서 `$PRINCIPAL_ID` 는 다음과 같을 수 있습니다:\
    `principalSet://iam.googleapis.com/projects/<THE_ACTUAL_GOOGLE_PROJECT_NUMBER>/locations/global/workloadIdentityPools/<THE_ACTUAL_POOL_ID>/attribute.account/<THE_ACTUAL_PANTHER_AWS_ACCOUNT_ID>`
    * `gcloud projects add-iam-policy-binding $PROJECT_ID --member="$PRINCIPAL_ID" --role="roles/pubsub.publisher"`

6. [자격 증명 구성 파일을 다운로드하세요](https://cloud.google.com/iam/docs/workload-download-cred-and-grant-access)Panther에서 GCP 인프라에 인증하는 데 사용됩니다.

* gcloud CLI 도구를 사용하여 자격 증명 구성 파일을 생성하려면 다음 명령 형식을 사용하세요:\
  `gcloud iam workload-identity-pools create-cred-config projects/$PROJECT_NUMBER/locations/global/workloadIdentityPools/$POOL_ID/providers/$PROVIDER_ID --aws --output-file=config.json`
  {% endtab %}
  {% endtabs %}

### 2단계: Panther에서 Google Pub/Sub 알러트 대상 구성

1. Panther Console에서 다음으로 이동합니다 **구성** > **알러트 대상.**
2. 을 클릭합니다 **+ 첫 번째 대상 추가**.
   * 이미 Destination을 생성한 경우에는 **새로 만들기** 를 페이지 오른쪽 상단에서 클릭하여 새 Destination을 추가합니다.
3. 을 클릭합니다 **Google Pub/Sub**.
4. Google Pub/Sub 대상을 구성하려면 양식을 작성하세요:
   * **표시 이름**: 설명적인 이름을 입력하세요.
   * **프로젝트 ID**: 프로젝트의 ID를 입력하세요.
   * **파일 업로드**: 에서 생성한 키 파일 또는 자격 증명 구성 파일을 추가하세요 [1단계](#step-1-create-required-google-cloud-platform-gcp-infrastructure).
   * **주제 ID**: 주제의 ID를 입력하세요.
   * **심각도**: 이 대상에 보낼 알러트의 심각도 수준을 선택하세요.
   * **알러트 유형**: 이 대상에 보낼 알러트 유형을 선택하세요.
   * **로그 유형**: 기본적으로 모든 로그 유형의 알러트를 보냅니다. 특정 로그 유형의 알러트만 보내려면 여기에서 로그 유형을 지정하세요.
   * **수동 전송 허용**: 이 토글을 ON으로 설정하면 [알러트를 수동으로 전송](https://docs.panther.com/alerts#manual-alert-dispatch) 할 수 있습니다.

     <figure><img src="https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-3fd7d0d99ee7612ad4d791c7b5de3ff2c6c8bf92%2FScreenshot%202025-03-24%20at%2011.26.54.png?alt=media" alt="Under a &#x22;Configure your GCP Pub/Sub Destination&#x22; header is a form with various fields, like Display Name, Project ID, and Topic ID. At the bottom is an &#x22;Add Destination&#x22; button." width="375"><figcaption></figcaption></figure>
5. 을 클릭합니다 **Destination 추가**.
6. 을 클릭합니다 **설정 완료** 를 눌러 설정을 완료하거나 **테스트 알러트 보내기** 를 눌러 설정을 테스트하세요.

## Destination에 대한 추가 정보

알러트 라우팅 순서, destination 수정 또는 삭제, 워크플로 자동화에 대한 자세한 내용은 Panther 문서를 참조하세요: [Destination](https://docs.panther.com/destinations).
