import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * A named resource to which messages are sent by publishers. * * To get more information about Topic, see: * * * [API documentation](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics) * * How-to Guides * * [Managing Topics](https://cloud.google.com/pubsub/docs/admin#managing_topics) * * > **Note:** You can retrieve the email of the Google Managed Pub/Sub Service Account used for forwarding * by using the `gcp.projects.ServiceIdentity` resource. * * ## Example Usage * * ### Pubsub Topic Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const example = new gcp.pubsub.Topic("example", { * name: "example-topic", * labels: { * foo: "bar", * }, * messageRetentionDuration: "86600s", * }); * ``` * ### Pubsub Topic Cmek * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const keyRing = new gcp.kms.KeyRing("key_ring", { * name: "example-keyring", * location: "global", * }); * const cryptoKey = new gcp.kms.CryptoKey("crypto_key", { * name: "example-key", * keyRing: keyRing.id, * }); * const example = new gcp.pubsub.Topic("example", { * name: "example-topic", * kmsKeyName: cryptoKey.id, * }); * ``` * ### Pubsub Topic Geo Restricted * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const example = new gcp.pubsub.Topic("example", { * name: "example-topic", * messageStoragePolicy: { * allowedPersistenceRegions: ["europe-west3"], * enforceInTransit: true, * }, * }); * ``` * ### Pubsub Topic Schema Settings * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const example = new gcp.pubsub.Schema("example", { * name: "example", * type: "AVRO", * definition: `{ * "type" : "record", * "name" : "Avro", * "fields" : [ * { * "name" : "StringField", * "type" : "string" * }, * { * "name" : "IntField", * "type" : "int" * } * ] * } * `, * }); * const exampleTopic = new gcp.pubsub.Topic("example", { * name: "example-topic", * schemaSettings: { * schema: "projects/my-project-name/schemas/example", * encoding: "JSON", * }, * }, { * dependsOn: [example], * }); * ``` * ### Pubsub Topic Ingestion Kinesis * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const example = new gcp.pubsub.Topic("example", { * name: "example-topic", * ingestionDataSourceSettings: { * awsKinesis: { * streamArn: "arn:aws:kinesis:us-west-2:111111111111:stream/fake-stream-name", * consumerArn: "arn:aws:kinesis:us-west-2:111111111111:stream/fake-stream-name/consumer/consumer-1:1111111111", * awsRoleArn: "arn:aws:iam::111111111111:role/fake-role-name", * gcpServiceAccount: "fake-service-account@fake-gcp-project.iam.gserviceaccount.com", * }, * }, * }); * ``` * ### Pubsub Topic Ingestion Cloud Storage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const example = new gcp.pubsub.Topic("example", { * name: "example-topic", * ingestionDataSourceSettings: { * cloudStorage: { * bucket: "test-bucket", * textFormat: { * delimiter: " ", * }, * minimumObjectCreateTime: "2024-01-01T00:00:00Z", * matchGlob: "foo/**", * }, * platformLogsSettings: { * severity: "WARNING", * }, * }, * }); * ``` * ### Pubsub Topic Ingestion Azure Event Hubs * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const example = new gcp.pubsub.Topic("example", { * name: "example-topic", * ingestionDataSourceSettings: { * azureEventHubs: { * resourceGroup: "azure-ingestion-resource-group", * namespace: "azure-ingestion-namespace", * eventHub: "azure-ingestion-event-hub", * clientId: "aZZZZZZZ-YYYY-HHHH-GGGG-abcdef569123", * tenantId: "0XXXXXXX-YYYY-HHHH-GGGG-123456789123", * subscriptionId: "bXXXXXXX-YYYY-HHHH-GGGG-123456789123", * gcpServiceAccount: "fake-service-account@fake-gcp-project.iam.gserviceaccount.com", * }, * }, * }); * ``` * ### Pubsub Topic Ingestion Aws Msk * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const example = new gcp.pubsub.Topic("example", { * name: "example-topic", * ingestionDataSourceSettings: { * awsMsk: { * clusterArn: "arn:aws:kinesis:us-west-2:111111111111:stream/fake-stream-name", * topic: "test-topic", * awsRoleArn: "arn:aws:iam::111111111111:role/fake-role-name", * gcpServiceAccount: "fake-service-account@fake-gcp-project.iam.gserviceaccount.com", * }, * }, * }); * ``` * ### Pubsub Topic Ingestion Confluent Cloud * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const example = new gcp.pubsub.Topic("example", { * name: "example-topic", * ingestionDataSourceSettings: { * confluentCloud: { * bootstrapServer: "test.us-west2.gcp.confluent.cloud:1111", * clusterId: "1234", * topic: "test-topic", * identityPoolId: "test-identity-pool-id", * gcpServiceAccount: "fake-service-account@fake-gcp-project.iam.gserviceaccount.com", * }, * }, * }); * ``` * ### Pubsub Topic Single Smt * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const example = new gcp.pubsub.Topic("example", { * name: "example-topic", * messageTransforms: [{ * javascriptUdf: { * functionName: "isYearEven", * code: `function isYearEven(message, metadata) { * const data = JSON.parse(message.data); * return message.year %2 === 0; * } * `, * }, * }], * }); * ``` * ### Pubsub Topic Multiple Smts * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const example = new gcp.pubsub.Topic("example", { * name: "example-topic", * messageTransforms: [ * { * javascriptUdf: { * functionName: "redactSSN", * code: `function redactSSN(message, metadata) { * const data = JSON.parse(message.data); * delete data['ssn']; * message.data = JSON.stringify(data); * return message; * } * `, * }, * }, * { * javascriptUdf: { * functionName: "otherFunc", * code: `function otherFunc(message, metadata) { * return null; * } * `, * }, * }, * { * disabled: true, * javascriptUdf: { * functionName: "someSMTWeDisabled", * code: "...", * }, * }, * ], * }); * ``` * ### Pubsub Topic Tags * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const project = gcp.organizations.getProject({}); * const example = new gcp.pubsub.Topic("example", { * name: "example-topic", * project: project.then(project => project.projectId), * }); * const tagKey = new gcp.tags.TagKey("tag_key", { * parent: project.then(project => project.id), * shortName: "tag_key", * }); * const tagValue = new gcp.tags.TagValue("tag_value", { * parent: tagKey.id, * shortName: "tag_value", * }); * const binding = new gcp.tags.TagBinding("binding", { * parent: pulumi.all([project, example.name]).apply(([project, name]) => `//pubsub.googleapis.com/projects/${project.number}/topics/${name}`), * tagValue: tagValue.id, * }); * ``` * * ## Import * * Topic can be imported using any of these accepted formats: * * * `projects/{{project}}/topics/{{name}}` * * `{{project}}/{{name}}` * * `{{name}}` * * When using the `pulumi import` command, Topic can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:pubsub/topic:Topic default projects/{{project}}/topics/{{name}} * $ pulumi import gcp:pubsub/topic:Topic default {{project}}/{{name}} * $ pulumi import gcp:pubsub/topic:Topic default {{name}} * ``` */ export declare class Topic extends pulumi.CustomResource { /** * Get an existing Topic resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input, state?: TopicState, opts?: pulumi.CustomResourceOptions): Topic; /** * Returns true if the given object is an instance of Topic. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is Topic; /** * All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services. */ readonly effectiveLabels: pulumi.Output<{ [key: string]: string; }>; /** * Settings for ingestion from a data source into this topic. * Structure is documented below. */ readonly ingestionDataSourceSettings: pulumi.Output; /** * The resource name of the Cloud KMS CryptoKey to be used to protect access * to messages published on this topic. Your project's PubSub service account * (`service-{{PROJECT_NUMBER}}@gcp-sa-pubsub.iam.gserviceaccount.com`) must have * `roles/cloudkms.cryptoKeyEncrypterDecrypter` to use this feature. * The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*` */ readonly kmsKeyName: pulumi.Output; /** * A set of key/value label pairs to assign to this Topic. * * **Note**: This field is non-authoritative, and will only manage the labels present in your configuration. * Please refer to the field `effectiveLabels` for all of the labels present on the resource. */ readonly labels: pulumi.Output<{ [key: string]: string; } | undefined>; /** * Indicates the minimum duration to retain a message after it is published * to the topic. If this field is set, messages published to the topic in * the last messageRetentionDuration are always available to subscribers. * For instance, it allows any attached subscription to seek to a timestamp * that is up to messageRetentionDuration in the past. If this field is not * set, message retention is controlled by settings on individual subscriptions. * The rotation period has the format of a decimal number, followed by the * letter `s` (seconds). Cannot be more than 31 days or less than 10 minutes. */ readonly messageRetentionDuration: pulumi.Output; /** * Policy constraining the set of Google Cloud Platform regions where * messages published to the topic may be stored. If not present, then no * constraints are in effect. * Structure is documented below. */ readonly messageStoragePolicy: pulumi.Output; /** * Transforms to be applied to messages published to the topic. Transforms are applied in the * order specified. * Structure is documented below. */ readonly messageTransforms: pulumi.Output; /** * Name of the topic. */ readonly name: pulumi.Output; /** * The ID of the project in which the resource belongs. * If it is not provided, the provider project is used. */ readonly project: pulumi.Output; /** * The combination of labels configured directly on the resource * and default labels configured on the provider. */ readonly pulumiLabels: pulumi.Output<{ [key: string]: string; }>; /** * Settings for validating messages published against a schema. * Structure is documented below. */ readonly schemaSettings: pulumi.Output; /** * Input only. Resource manager tags to be bound to the topic. Tag keys and * values have the same definition as resource manager tags. Keys must be in * the format tagKeys/{tag_key_id}, and values are in the format * tagValues/456. The field is ignored when empty. The field is immutable and * causes resource replacement when mutated. This field is only set at create * time and modifying this field after creation will trigger recreation. To * apply tags to an existing resource, see the `gcp.tags.TagValue` * resource. */ readonly tags: pulumi.Output<{ [key: string]: string; } | undefined>; /** * Create a Topic resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: TopicArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering Topic resources. */ export interface TopicState { /** * All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services. */ effectiveLabels?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * Settings for ingestion from a data source into this topic. * Structure is documented below. */ ingestionDataSourceSettings?: pulumi.Input; /** * The resource name of the Cloud KMS CryptoKey to be used to protect access * to messages published on this topic. Your project's PubSub service account * (`service-{{PROJECT_NUMBER}}@gcp-sa-pubsub.iam.gserviceaccount.com`) must have * `roles/cloudkms.cryptoKeyEncrypterDecrypter` to use this feature. * The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*` */ kmsKeyName?: pulumi.Input; /** * A set of key/value label pairs to assign to this Topic. * * **Note**: This field is non-authoritative, and will only manage the labels present in your configuration. * Please refer to the field `effectiveLabels` for all of the labels present on the resource. */ labels?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * Indicates the minimum duration to retain a message after it is published * to the topic. If this field is set, messages published to the topic in * the last messageRetentionDuration are always available to subscribers. * For instance, it allows any attached subscription to seek to a timestamp * that is up to messageRetentionDuration in the past. If this field is not * set, message retention is controlled by settings on individual subscriptions. * The rotation period has the format of a decimal number, followed by the * letter `s` (seconds). Cannot be more than 31 days or less than 10 minutes. */ messageRetentionDuration?: pulumi.Input; /** * Policy constraining the set of Google Cloud Platform regions where * messages published to the topic may be stored. If not present, then no * constraints are in effect. * Structure is documented below. */ messageStoragePolicy?: pulumi.Input; /** * Transforms to be applied to messages published to the topic. Transforms are applied in the * order specified. * Structure is documented below. */ messageTransforms?: pulumi.Input[]>; /** * Name of the topic. */ name?: pulumi.Input; /** * The ID of the project in which the resource belongs. * If it is not provided, the provider project is used. */ project?: pulumi.Input; /** * The combination of labels configured directly on the resource * and default labels configured on the provider. */ pulumiLabels?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * Settings for validating messages published against a schema. * Structure is documented below. */ schemaSettings?: pulumi.Input; /** * Input only. Resource manager tags to be bound to the topic. Tag keys and * values have the same definition as resource manager tags. Keys must be in * the format tagKeys/{tag_key_id}, and values are in the format * tagValues/456. The field is ignored when empty. The field is immutable and * causes resource replacement when mutated. This field is only set at create * time and modifying this field after creation will trigger recreation. To * apply tags to an existing resource, see the `gcp.tags.TagValue` * resource. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; }>; } /** * The set of arguments for constructing a Topic resource. */ export interface TopicArgs { /** * Settings for ingestion from a data source into this topic. * Structure is documented below. */ ingestionDataSourceSettings?: pulumi.Input; /** * The resource name of the Cloud KMS CryptoKey to be used to protect access * to messages published on this topic. Your project's PubSub service account * (`service-{{PROJECT_NUMBER}}@gcp-sa-pubsub.iam.gserviceaccount.com`) must have * `roles/cloudkms.cryptoKeyEncrypterDecrypter` to use this feature. * The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*` */ kmsKeyName?: pulumi.Input; /** * A set of key/value label pairs to assign to this Topic. * * **Note**: This field is non-authoritative, and will only manage the labels present in your configuration. * Please refer to the field `effectiveLabels` for all of the labels present on the resource. */ labels?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * Indicates the minimum duration to retain a message after it is published * to the topic. If this field is set, messages published to the topic in * the last messageRetentionDuration are always available to subscribers. * For instance, it allows any attached subscription to seek to a timestamp * that is up to messageRetentionDuration in the past. If this field is not * set, message retention is controlled by settings on individual subscriptions. * The rotation period has the format of a decimal number, followed by the * letter `s` (seconds). Cannot be more than 31 days or less than 10 minutes. */ messageRetentionDuration?: pulumi.Input; /** * Policy constraining the set of Google Cloud Platform regions where * messages published to the topic may be stored. If not present, then no * constraints are in effect. * Structure is documented below. */ messageStoragePolicy?: pulumi.Input; /** * Transforms to be applied to messages published to the topic. Transforms are applied in the * order specified. * Structure is documented below. */ messageTransforms?: pulumi.Input[]>; /** * Name of the topic. */ name?: pulumi.Input; /** * The ID of the project in which the resource belongs. * If it is not provided, the provider project is used. */ project?: pulumi.Input; /** * Settings for validating messages published against a schema. * Structure is documented below. */ schemaSettings?: pulumi.Input; /** * Input only. Resource manager tags to be bound to the topic. Tag keys and * values have the same definition as resource manager tags. Keys must be in * the format tagKeys/{tag_key_id}, and values are in the format * tagValues/456. The field is ignored when empty. The field is immutable and * causes resource replacement when mutated. This field is only set at create * time and modifying this field after creation will trigger recreation. To * apply tags to an existing resource, see the `gcp.tags.TagValue` * resource. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; }>; }