UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

430 lines • 14.9 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Topic = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * 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}} * ``` */ 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, id, state, opts) { return new Topic(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:pubsub/topic: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) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Topic.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["effectiveLabels"] = state?.effectiveLabels; resourceInputs["ingestionDataSourceSettings"] = state?.ingestionDataSourceSettings; resourceInputs["kmsKeyName"] = state?.kmsKeyName; resourceInputs["labels"] = state?.labels; resourceInputs["messageRetentionDuration"] = state?.messageRetentionDuration; resourceInputs["messageStoragePolicy"] = state?.messageStoragePolicy; resourceInputs["messageTransforms"] = state?.messageTransforms; resourceInputs["name"] = state?.name; resourceInputs["project"] = state?.project; resourceInputs["pulumiLabels"] = state?.pulumiLabels; resourceInputs["schemaSettings"] = state?.schemaSettings; resourceInputs["tags"] = state?.tags; } else { const args = argsOrState; resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["ingestionDataSourceSettings"] = args?.ingestionDataSourceSettings; resourceInputs["kmsKeyName"] = args?.kmsKeyName; resourceInputs["labels"] = args?.labels; resourceInputs["messageRetentionDuration"] = args?.messageRetentionDuration; resourceInputs["messageStoragePolicy"] = args?.messageStoragePolicy; resourceInputs["messageTransforms"] = args?.messageTransforms; resourceInputs["name"] = args?.name; resourceInputs["project"] = args?.project; resourceInputs["schemaSettings"] = args?.schemaSettings; resourceInputs["tags"] = args?.tags; resourceInputs["effectiveLabels"] = undefined /*out*/; resourceInputs["pulumiLabels"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Topic.__pulumiType, name, resourceInputs, opts); } } exports.Topic = Topic; //# sourceMappingURL=topic.js.map