Docs / Contact / connectors/gcp-pubsub

Google Pub/Sub

Provider: gcp | Service: pubsub | Direction: Write

Google Cloud Pub/Sub connector for publishing messages to a topic.

Required Permissions

The service account must have:

Operation Required Permission Predefined Role
Publish pubsub.topics.publish Pub/Sub Publisher
Tip: Grant the role at the topic level for least privilege rather than at the project level.

Operation

When a message reaches this connector, it publishes to the configured topic. The payload must supply:

Payload field Required Description
message Yes Message body to publish

Connector Configuration

The connector is created with type: "cloud", provider: "gcp", service_type: "pubsub", plus:

Field (config) Required Description
auth_type No api_key (default) or role. See below.
project_id Yes Google Cloud project ID
credentials Conditional Service account JSON credentials (use ${secrets.gcp_credentials}). Required when auth_type is api_key.
topic_id Yes Pub/Sub topic ID
Role-based authentication

Set auth_type: "role" to use Application Default Credentials (ADC) from the environment Contact runs in. No service account JSON is needed.

Output

json

{
  "status": "completed",
  "data": {
    "status": "published"
  }
}

Example

Connector config (service account):

json

{
  "type": "cloud",
  "provider": "gcp",
  "service_type": "pubsub",
  "project_id": "my-gcp-project",
  "credentials": "${secrets.gcp_credentials}",
  "topic_id": "device-events"
}

Connector config (ADC / role):

json

{
  "type": "cloud",
  "provider": "gcp",
  "service_type": "pubsub",
  "auth_type": "role",
  "project_id": "my-gcp-project",
  "topic_id": "device-events"
}