@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
64 lines (63 loc) • 2.57 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as cloudfunctions from "../cloudfunctions";
/**
* Arguments that can be provided to control the Cloud Function created as the serverless endpoint
* for a topic event.
*/
export interface TopicEventCallbackFunctionArgs extends cloudfunctions.CallbackFunctionArgs {
callback?: TopicEventHandler;
callbackFactory?: () => TopicEventHandler;
httpsTriggerUrl?: never;
triggerHttp?: never;
eventTrigger?: never;
}
/**
* Arguments to control how GCP will respond if the Cloud Function fails. Currently, the only
* specialized behavior supported is to attempt retrying the Cloud Function.
* See [cloudfunctions.FailurePolicy] for more information on this.
*/
export interface TopicMessagePublishedArgs {
failurePolicy?: cloudfunctions.FailurePolicy;
}
/**
* Shape of the [context] object passed to a Cloud Function when a topic event fires.
*/
export interface TopicContext extends cloudfunctions.Context {
eventType: "google.pubsub.topic.publish";
resource: {
service: "pubsub.googleapis.com";
name: string;
type: "type.googleapis.com/google.pubsub.v1.PubsubMessage";
};
}
/**
* Shape of the [data] object passed to a Cloud Function when a topic event fires.
*
* See https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage for more details.
*/
export interface TopicData {
"@type": "type.googleapis.com/google.pubsub.v1.PubsubMessage";
/**
* key/value pairs included with the topic even.
*/
attributes: Record<string, string>;
/**
* Base64 encoded data. Use `Buffer.from(pubSubMessage.data, 'base64')` to get raw bytes of the
* message.
*/
data: string;
}
export type TopicEventHandler = cloudfunctions.Callback<TopicData, TopicContext, void>;
declare module "./topic" {
interface Topic {
/**
* Creates and publishes a Cloud Functions that will be triggered by messages published to
* Cloud Pub/Sub topics in the same GCP project as the Function. Cloud Pub/Sub is a globally
* distributed message bus that automatically scales as you need it and provides a
* foundation for building your own robust, global services.
*
* See https://cloud.google.com/functions/docs/calling/pubsub for more details.
*/
onMessagePublished(name: string, handler: TopicEventHandler | TopicEventCallbackFunctionArgs, args?: TopicMessagePublishedArgs, opts?: pulumi.ComponentResourceOptions): cloudfunctions.CallbackFunction;
}
}