Eventarc 위치 이해

각 이벤트 소스, 이벤트 대상, Eventarc 트리거에는 자체적인 위치가 있습니다. 어떤 경우에는 이러한 위치가 일치해야 하며 어떤 경우에는 달라도 됩니다. 자세한 내용은 Eventarc 위치를 참조하세요.

소스 위치

이벤트 소스의 위치에 따라 트리거 위치가 결정되는 경우가 많습니다. 다음 예시에서 Cloud Storage 버킷이 europe-west1 리전에 있으므로 트리거도 europe-west1에 있어야 합니다.

gcloud eventarc triggers create trigger-storage \
  --destination-run-service=hello \
  --destination-run-region=us-central1 \
  --location=europe-west1 \
  --event-filters="type=google.cloud.storage.object.v1.finalized" \
  --event-filters="bucket=my-bucket-in-europe-west1-region" \
  --service-account=$PROJECT_NUMBER-compute@developer.gserviceaccount.com

대상 위치

이벤트 대상(예: Cloud Run 서비스)을 배포할 때 지원되는 리전을 위치로 선택합니다. 일반적으로 지연 시간과 데이터 지역 이유로 인해 이벤트 소스와 동일한 리전에 있는 것이 좋습니다. 그러나 이는 필수가 아닙니다. 앞의 예시에서 이벤트 소스는 europe-west1에 있는 반면 --destination-run-region 플래그는 이벤트 대상이 us-central1에 있음을 나타냅니다.

트리거 위치

또한 만드는 Eventarc 트리거 유형은 --location 플래그를 통해 지정된 트리거의 위치에 영향을 줍니다.

Cloud 감사 로그

Cloud 감사 로그 트리거를 사용하면 감사 로그를 내보내는 모든 이벤트 소스를 이벤트 대상에 연결할 수 있습니다. Cloud 감사 로그 트리거는 단일 리전 위치에서 사용할 수 있으며 전역 Eventarc 트리거를 만들 수 있습니다. 그러나 이중 리전 및 멀티 리전 위치에서는 트리거가 지원되지 않습니다.

이벤트 소스의 위치에 따라 트리거 위치가 결정됩니다. 일반적으로 이 위치는 단일 리전 위치입니다. 예를 들어 감사 로그 트리거로 europe-west1 리전에 있는 버킷에서 발생한 Cloud Storage 이벤트를 캡처하려면 동일한 위치에 트리거를 만듭니다.

gcloud eventarc triggers create trigger-auditlog \
  --destination-run-service=hello \
  --destination-run-region=us-central1 \
  --location=europe-west1 \
  --event-filters="type=google.cloud.audit.log.v1.written" \
  --event-filters="serviceName=storage.googleapis.com" \
  --event-filters="methodName=storage.objects.create" \
  --service-account=$PROJECT_NUMBER-compute@developer.gserviceaccount.com

Cloud 감사 로그 트리거를 사용하는 경우 버킷별 필터링이 없으므로 europe-west1 리전의 모든 버킷과 일치하게 됩니다. (버킷별로 필터링하려면 직접 Cloud Storage 트리거를 사용하면 됩니다.)

또는 eu와 같은 이중 리전이나 멀티 리전 버킷과 일치시키려면 global 위치를 사용하여 트리거를 만들면 됩니다. 그러면 모든 리전 내 모든 버킷이 다음과 일치하는 이벤트 필터와 일치합니다.

gcloud eventarc triggers create trigger-storage \
  --destination-run-service=hello \
  --destination-run-region=us-central1 \
  --location=global \
  --event-filters="type=google.cloud.storage.object.v1.finalized" \
  --event-filters="bucket=my-bucket-in-europe-west1-region" \
  --service-account=$PROJECT_NUMBER-compute@developer.gserviceaccount.com

Cloud Storage

Cloud Storage 트리거는 객체 생성, 삭제, 보관처리, 메타데이터 업데이트와 같은 Cloud Storage 버킷 내 이벤트에 응답합니다. Cloud Storage 트리거는 단일 리전, 이중 리전, 멀티 리전 위치에서 사용할 수 있습니다. 전역 Eventarc 트리거는 만들 수 없습니다.

Cloud Storage 버킷 위치는 Eventarc 트리거 위치를 결정하며 반드시 일치해야 합니다. 다음 예시에서 트리거 위치는 Cloud Storage 버킷(eu 멀티 리전 위치) 위치와 일치합니다.

gcloud eventarc triggers create trigger-storage \
  --destination-run-service=hello \
  --destination-run-region=us-central1 \
  --location=eu \
  --event-filters="type=google.cloud.storage.object.v1.finalized" \
  --event-filters="bucket=my-bucket-in-eu-multi-region" \
  --service-account=$PROJECT_NUMBER-compute@developer.gserviceaccount.com

버킷과 트리거 리전이 일치하지 않으면 다음과 유사한 오류가 표시됩니다.

ERROR: (gcloud.eventarc.triggers.create) INVALID_ARGUMENT: The request was
invalid: Bucket "my-bucket-in-eu-multi-region" location "eu" does not match
trigger location "europe-west1". Try again by creating the trigger in "eu".

Pub/Sub

Pub/Sub 트리거는 Pub/Sub 주제를 이벤트 대상에 연결합니다. 단일 리전 위치에서만 Pub/Sub 트리거를 사용할 수 있으며 전역 Eventarc 트리거를 만들 수 없습니다.

Pub/Sub 주제는 전역 리소스이며 단일 리전에 연결되지 않지만 Pub/Sub 트리거를 만들 때 --location 플래그를 사용하여 리전을 지정해야 합니다.

gcloud eventarc triggers create trigger-pubsub \
--destination-run-service=hello \
--destination-run-region=us-central1 \
--location=us-central1 \
--event-filters="type=google.cloud.pubsub.topic.v1.messagePublished" \
--transport-topic=projects/your-projectid/topics/your-topic

Eventarc는 Pub/Sub 이벤트가 지정된 위치에서만 지속되도록 지오펜싱을 구성합니다. 또한 모든 데이터가 단일 리전에 유지되도록 리전 Pub/Sub 서비스 엔드포인트를 사용하여 주제에 게시할 수도 있습니다.

다음 단계

  • 여러 Google Cloud 프로젝트에 걸쳐 이벤트를 라우팅하는 방법을 알아보려면 튜토리얼을 참조하세요.