Docs / Strand / connectors/gcp-pubsub
Google Pub/Sub
Direction: Read / Write | Type: gcp.pubsub
Google Cloud Pub/Sub connector for publishing messages to topics and receiving messages from subscriptions.
Required Permissions
The service account must have the following IAM permissions (or predefined roles):
| Operation | Required Permissions | Predefined Role |
|---|---|---|
publish |
pubsub.topics.publish |
Pub/Sub Publisher |
subscribe |
pubsub.subscriptions.consume |
Pub/Sub Subscriber |
Tip: Grant roles at the topic or subscription level for least privilege rather than at the project level.
Operations
| Operation | Direction | Description |
|---|---|---|
publish |
Write | Publish a message to a topic |
subscribe |
Read | Receive a message from a subscription |
Connector Configuration
| Field | Required | Default | Description |
|---|---|---|---|
| Authentication Type | No | api_key |
api_key for explicit credentials, role to use Application Default Credentials (ADC) |
| Project ID | Yes | - | Google Cloud project ID |
| Credentials JSON | Conditional | - | Service account JSON credentials (encrypted). Required when Authentication Type is api_key |
| Topic Name | No | - | Default topic name (can be overridden at node level) |
| Subscription Name | No | - | Default subscription name (can be overridden at node level) |
Role-Based Authentication
When using role authentication, the connector uses Application Default Credentials (ADC) from the host environment. No explicit service account JSON is needed.
Node Configuration
| Field | Required | Description |
|---|---|---|
| Operation | Yes | publish or subscribe |
| Topic Name | No | Pub/Sub topic name (for publish) |
| Subscription Name | No | Subscription name (for subscribe) |
Output
publish
json
{
"success": true,
"status": "sent",
"data": {
"message_id": "123456789",
"topic": "my-topic"
},
"service": "gcp.pubsub",
"operation": "publish"
}
subscribe
json
{
"success": true,
"status": "received",
"data": {
"subscription": "my-subscription",
"message": {"key": "value"}
},
"service": "gcp.pubsub",
"operation": "subscribe"
}
When no messages are available:
json
{
"success": true,
"status": "empty",
"data": {
"subscription": "my-subscription",
"message": null
},
"service": "gcp.pubsub",
"operation": "subscribe"
}
Example
Connector Setup:
json
{
"project_id": "my-gcp-project",
"credentials_json": "{...service account JSON...}",
"topic_name": "order-events",
"subscription_name": "order-processor"
}
Connector Setup (role-based):
json
{
"auth_type": "role",
"project_id": "my-gcp-project",
"topic_name": "order-events",
"subscription_name": "order-processor"
}
Node Configuration (publish):
- Operation:
publish
Node Configuration (subscribe):
- Operation:
subscribe
Tendrl