@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
643 lines • 25.1 kB
TypeScript
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,
* });
* ```
* ### Pubsub Topic Ai Inference
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* import * as time from "@pulumiverse/time";
*
* const geminiQueryServiceAccount = new gcp.serviceaccount.Account("gemini_query_service_account", {
* accountId: "example-sa",
* displayName: "Gemini Query Service Account",
* });
* const geminiInferenceGet = new gcp.projects.IAMMember("gemini_inference_get", {
* project: "my-project-name",
* role: "roles/aiplatform.user",
* member: pulumi.interpolate`serviceAccount:${geminiQueryServiceAccount.email}`,
* });
* const wait120Seconds = new time.Sleep("wait_120_seconds", {createDuration: "120s"}, {
* dependsOn: [geminiInferenceGet],
* });
* const example = new gcp.pubsub.Topic("example", {
* name: "example-topic",
* messageTransforms: [{
* aiInference: {
* endpoint: "projects/my-project-name/locations/us-central1/publishers/google/models/gemini-2.5-flash",
* unstructuredInference: {
* parameters: {
* max_tokens: "25000",
* },
* },
* serviceAccountEmail: geminiQueryServiceAccount.email,
* },
* }],
* }, {
* dependsOn: [wait120Seconds],
* });
* ```
*
* ## 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<pulumi.ID>, 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;
/**
* Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
* When a 'terraform destroy' or 'pulumi up' would delete the resource,
* the command will fail if this field is set to "PREVENT" in Terraform state.
* When set to "ABANDON", the command will remove the resource from Terraform
* management without updating or deleting the resource in the API.
* When set to "DELETE", deleting the resource is allowed.
*/
readonly deletionPolicy: pulumi.Output<string>;
/**
* 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<outputs.pubsub.TopicIngestionDataSourceSettings | undefined>;
/**
* 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<string | undefined>;
/**
* 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<string | undefined>;
/**
* 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<outputs.pubsub.TopicMessageStoragePolicy>;
/**
* 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<outputs.pubsub.TopicMessageTransform[] | undefined>;
/**
* Name of the topic.
*/
readonly name: pulumi.Output<string>;
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
readonly project: pulumi.Output<string>;
/**
* 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<outputs.pubsub.TopicSchemaSettings | undefined>;
/**
* 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 {
/**
* Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
* When a 'terraform destroy' or 'pulumi up' would delete the resource,
* the command will fail if this field is set to "PREVENT" in Terraform state.
* When set to "ABANDON", the command will remove the resource from Terraform
* management without updating or deleting the resource in the API.
* When set to "DELETE", deleting the resource is allowed.
*/
deletionPolicy?: pulumi.Input<string | undefined>;
/**
* 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<string>;
} | undefined>;
/**
* Settings for ingestion from a data source into this topic.
* Structure is documented below.
*/
ingestionDataSourceSettings?: pulumi.Input<inputs.pubsub.TopicIngestionDataSourceSettings | undefined>;
/**
* 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<string | undefined>;
/**
* 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<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.
*/
messageRetentionDuration?: pulumi.Input<string | undefined>;
/**
* 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<inputs.pubsub.TopicMessageStoragePolicy | undefined>;
/**
* Transforms to be applied to messages published to the topic. Transforms are applied in the
* order specified.
* Structure is documented below.
*/
messageTransforms?: pulumi.Input<pulumi.Input<inputs.pubsub.TopicMessageTransform>[] | undefined>;
/**
* Name of the topic.
*/
name?: pulumi.Input<string | undefined>;
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
project?: pulumi.Input<string | undefined>;
/**
* The combination of labels configured directly on the resource
* and default labels configured on the provider.
*/
pulumiLabels?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
} | undefined>;
/**
* Settings for validating messages published against a schema.
* Structure is documented below.
*/
schemaSettings?: pulumi.Input<inputs.pubsub.TopicSchemaSettings | undefined>;
/**
* 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<string>;
} | undefined>;
}
/**
* The set of arguments for constructing a Topic resource.
*/
export interface TopicArgs {
/**
* Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
* When a 'terraform destroy' or 'pulumi up' would delete the resource,
* the command will fail if this field is set to "PREVENT" in Terraform state.
* When set to "ABANDON", the command will remove the resource from Terraform
* management without updating or deleting the resource in the API.
* When set to "DELETE", deleting the resource is allowed.
*/
deletionPolicy?: pulumi.Input<string | undefined>;
/**
* Settings for ingestion from a data source into this topic.
* Structure is documented below.
*/
ingestionDataSourceSettings?: pulumi.Input<inputs.pubsub.TopicIngestionDataSourceSettings | undefined>;
/**
* 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<string | undefined>;
/**
* 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<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.
*/
messageRetentionDuration?: pulumi.Input<string | undefined>;
/**
* 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<inputs.pubsub.TopicMessageStoragePolicy | undefined>;
/**
* Transforms to be applied to messages published to the topic. Transforms are applied in the
* order specified.
* Structure is documented below.
*/
messageTransforms?: pulumi.Input<pulumi.Input<inputs.pubsub.TopicMessageTransform>[] | undefined>;
/**
* Name of the topic.
*/
name?: pulumi.Input<string | undefined>;
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
project?: pulumi.Input<string | undefined>;
/**
* Settings for validating messages published against a schema.
* Structure is documented below.
*/
schemaSettings?: pulumi.Input<inputs.pubsub.TopicSchemaSettings | undefined>;
/**
* 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<string>;
} | undefined>;
}
//# sourceMappingURL=topic.d.ts.map