All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.gcp.pubsub.kotlin.Topic.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 8.10.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.pubsub.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.pubsub.kotlin.outputs.TopicIngestionDataSourceSettings
import com.pulumi.gcp.pubsub.kotlin.outputs.TopicMessageStoragePolicy
import com.pulumi.gcp.pubsub.kotlin.outputs.TopicSchemaSettings
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map
import com.pulumi.gcp.pubsub.kotlin.outputs.TopicIngestionDataSourceSettings.Companion.toKotlin as topicIngestionDataSourceSettingsToKotlin
import com.pulumi.gcp.pubsub.kotlin.outputs.TopicMessageStoragePolicy.Companion.toKotlin as topicMessageStoragePolicyToKotlin
import com.pulumi.gcp.pubsub.kotlin.outputs.TopicSchemaSettings.Companion.toKotlin as topicSchemaSettingsToKotlin

/**
 * Builder for [Topic].
 */
@PulumiTagMarker
public class TopicResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: TopicArgs = TopicArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend TopicArgsBuilder.() -> Unit) {
        val builder = TopicArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): Topic {
        val builtJavaResource = com.pulumi.gcp.pubsub.Topic(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Topic(builtJavaResource)
    }
}

/**
 * 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",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * example = gcp.pubsub.Topic("example",
 *     name="example-topic",
 *     labels={
 *         "foo": "bar",
 *     },
 *     message_retention_duration="86600s")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Gcp.PubSub.Topic("example", new()
 *     {
 *         Name = "example-topic",
 *         Labels =
 *         {
 *             { "foo", "bar" },
 *         },
 *         MessageRetentionDuration = "86600s",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/pubsub"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := pubsub.NewTopic(ctx, "example", &pubsub.TopicArgs{
 * 			Name: pulumi.String("example-topic"),
 * 			Labels: pulumi.StringMap{
 * 				"foo": pulumi.String("bar"),
 * 			},
 * 			MessageRetentionDuration: pulumi.String("86600s"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.pubsub.Topic;
 * import com.pulumi.gcp.pubsub.TopicArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var example = new Topic("example", TopicArgs.builder()
 *             .name("example-topic")
 *             .labels(Map.of("foo", "bar"))
 *             .messageRetentionDuration("86600s")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: gcp:pubsub:Topic
 *     properties:
 *       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,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * key_ring = gcp.kms.KeyRing("key_ring",
 *     name="example-keyring",
 *     location="global")
 * crypto_key = gcp.kms.CryptoKey("crypto_key",
 *     name="example-key",
 *     key_ring=key_ring.id)
 * example = gcp.pubsub.Topic("example",
 *     name="example-topic",
 *     kms_key_name=crypto_key.id)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var keyRing = new Gcp.Kms.KeyRing("key_ring", new()
 *     {
 *         Name = "example-keyring",
 *         Location = "global",
 *     });
 *     var cryptoKey = new Gcp.Kms.CryptoKey("crypto_key", new()
 *     {
 *         Name = "example-key",
 *         KeyRing = keyRing.Id,
 *     });
 *     var example = new Gcp.PubSub.Topic("example", new()
 *     {
 *         Name = "example-topic",
 *         KmsKeyName = cryptoKey.Id,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/kms"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/pubsub"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		keyRing, err := kms.NewKeyRing(ctx, "key_ring", &kms.KeyRingArgs{
 * 			Name:     pulumi.String("example-keyring"),
 * 			Location: pulumi.String("global"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		cryptoKey, err := kms.NewCryptoKey(ctx, "crypto_key", &kms.CryptoKeyArgs{
 * 			Name:    pulumi.String("example-key"),
 * 			KeyRing: keyRing.ID(),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = pubsub.NewTopic(ctx, "example", &pubsub.TopicArgs{
 * 			Name:       pulumi.String("example-topic"),
 * 			KmsKeyName: cryptoKey.ID(),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.kms.KeyRing;
 * import com.pulumi.gcp.kms.KeyRingArgs;
 * import com.pulumi.gcp.kms.CryptoKey;
 * import com.pulumi.gcp.kms.CryptoKeyArgs;
 * import com.pulumi.gcp.pubsub.Topic;
 * import com.pulumi.gcp.pubsub.TopicArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var keyRing = new KeyRing("keyRing", KeyRingArgs.builder()
 *             .name("example-keyring")
 *             .location("global")
 *             .build());
 *         var cryptoKey = new CryptoKey("cryptoKey", CryptoKeyArgs.builder()
 *             .name("example-key")
 *             .keyRing(keyRing.id())
 *             .build());
 *         var example = new Topic("example", TopicArgs.builder()
 *             .name("example-topic")
 *             .kmsKeyName(cryptoKey.id())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: gcp:pubsub:Topic
 *     properties:
 *       name: example-topic
 *       kmsKeyName: ${cryptoKey.id}
 *   cryptoKey:
 *     type: gcp:kms:CryptoKey
 *     name: crypto_key
 *     properties:
 *       name: example-key
 *       keyRing: ${keyRing.id}
 *   keyRing:
 *     type: gcp:kms:KeyRing
 *     name: key_ring
 *     properties:
 *       name: example-keyring
 *       location: global
 * ```
 * 
 * ### 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"],
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * example = gcp.pubsub.Topic("example",
 *     name="example-topic",
 *     message_storage_policy=gcp.pubsub.TopicMessageStoragePolicyArgs(
 *         allowed_persistence_regions=["europe-west3"],
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Gcp.PubSub.Topic("example", new()
 *     {
 *         Name = "example-topic",
 *         MessageStoragePolicy = new Gcp.PubSub.Inputs.TopicMessageStoragePolicyArgs
 *         {
 *             AllowedPersistenceRegions = new[]
 *             {
 *                 "europe-west3",
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/pubsub"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := pubsub.NewTopic(ctx, "example", &pubsub.TopicArgs{
 * 			Name: pulumi.String("example-topic"),
 * 			MessageStoragePolicy: &pubsub.TopicMessageStoragePolicyArgs{
 * 				AllowedPersistenceRegions: pulumi.StringArray{
 * 					pulumi.String("europe-west3"),
 * 				},
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.pubsub.Topic;
 * import com.pulumi.gcp.pubsub.TopicArgs;
 * import com.pulumi.gcp.pubsub.inputs.TopicMessageStoragePolicyArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var example = new Topic("example", TopicArgs.builder()
 *             .name("example-topic")
 *             .messageStoragePolicy(TopicMessageStoragePolicyArgs.builder()
 *                 .allowedPersistenceRegions("europe-west3")
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: gcp:pubsub:Topic
 *     properties:
 *       name: example-topic
 *       messageStoragePolicy:
 *         allowedPersistenceRegions:
 *           - europe-west3
 * ```
 * 
 * ### 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",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * example = gcp.pubsub.Schema("example",
 *     name="example",
 *     type="AVRO",
 *     definition="""{
 *   "type" : "record",
 *   "name" : "Avro",
 *   "fields" : [
 *     {
 *       "name" : "StringField",
 *       "type" : "string"
 *     },
 *     {
 *       "name" : "IntField",
 *       "type" : "int"
 *     }
 *   ]
 * }
 * """)
 * example_topic = gcp.pubsub.Topic("example",
 *     name="example-topic",
 *     schema_settings=gcp.pubsub.TopicSchemaSettingsArgs(
 *         schema="projects/my-project-name/schemas/example",
 *         encoding="JSON",
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Gcp.PubSub.Schema("example", new()
 *     {
 *         Name = "example",
 *         Type = "AVRO",
 *         Definition = @"{
 *   ""type"" : ""record"",
 *   ""name"" : ""Avro"",
 *   ""fields"" : [
 *     {
 *       ""name"" : ""StringField"",
 *       ""type"" : ""string""
 *     },
 *     {
 *       ""name"" : ""IntField"",
 *       ""type"" : ""int""
 *     }
 *   ]
 * }
 * ",
 *     });
 *     var exampleTopic = new Gcp.PubSub.Topic("example", new()
 *     {
 *         Name = "example-topic",
 *         SchemaSettings = new Gcp.PubSub.Inputs.TopicSchemaSettingsArgs
 *         {
 *             Schema = "projects/my-project-name/schemas/example",
 *             Encoding = "JSON",
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/pubsub"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := pubsub.NewSchema(ctx, "example", &pubsub.SchemaArgs{
 * 			Name: pulumi.String("example"),
 * 			Type: pulumi.String("AVRO"),
 * 			Definition: pulumi.String(`{
 *   "type" : "record",
 *   "name" : "Avro",
 *   "fields" : [
 *     {
 *       "name" : "StringField",
 *       "type" : "string"
 *     },
 *     {
 *       "name" : "IntField",
 *       "type" : "int"
 *     }
 *   ]
 * }
 * `),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = pubsub.NewTopic(ctx, "example", &pubsub.TopicArgs{
 * 			Name: pulumi.String("example-topic"),
 * 			SchemaSettings: &pubsub.TopicSchemaSettingsArgs{
 * 				Schema:   pulumi.String("projects/my-project-name/schemas/example"),
 * 				Encoding: pulumi.String("JSON"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.pubsub.Schema;
 * import com.pulumi.gcp.pubsub.SchemaArgs;
 * import com.pulumi.gcp.pubsub.Topic;
 * import com.pulumi.gcp.pubsub.TopicArgs;
 * import com.pulumi.gcp.pubsub.inputs.TopicSchemaSettingsArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var example = new Schema("example", SchemaArgs.builder()
 *             .name("example")
 *             .type("AVRO")
 *             .definition("""
 * {
 *   "type" : "record",
 *   "name" : "Avro",
 *   "fields" : [
 *     {
 *       "name" : "StringField",
 *       "type" : "string"
 *     },
 *     {
 *       "name" : "IntField",
 *       "type" : "int"
 *     }
 *   ]
 * }
 *             """)
 *             .build());
 *         var exampleTopic = new Topic("exampleTopic", TopicArgs.builder()
 *             .name("example-topic")
 *             .schemaSettings(TopicSchemaSettingsArgs.builder()
 *                 .schema("projects/my-project-name/schemas/example")
 *                 .encoding("JSON")
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: gcp:pubsub:Schema
 *     properties:
 *       name: example
 *       type: AVRO
 *       definition: |
 *         {
 *           "type" : "record",
 *           "name" : "Avro",
 *           "fields" : [
 *             {
 *               "name" : "StringField",
 *               "type" : "string"
 *             },
 *             {
 *               "name" : "IntField",
 *               "type" : "int"
 *             }
 *           ]
 *         }
 *   exampleTopic:
 *     type: gcp:pubsub:Topic
 *     name: example
 *     properties:
 *       name: example-topic
 *       schemaSettings:
 *         schema: projects/my-project-name/schemas/example
 *         encoding: JSON
 * ```
 * 
 * ### 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: "[email protected]",
 *         },
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * example = gcp.pubsub.Topic("example",
 *     name="example-topic",
 *     ingestion_data_source_settings=gcp.pubsub.TopicIngestionDataSourceSettingsArgs(
 *         aws_kinesis=gcp.pubsub.TopicIngestionDataSourceSettingsAwsKinesisArgs(
 *             stream_arn="arn:aws:kinesis:us-west-2:111111111111:stream/fake-stream-name",
 *             consumer_arn="arn:aws:kinesis:us-west-2:111111111111:stream/fake-stream-name/consumer/consumer-1:1111111111",
 *             aws_role_arn="arn:aws:iam::111111111111:role/fake-role-name",
 *             gcp_service_account="[email protected]",
 *         ),
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Gcp.PubSub.Topic("example", new()
 *     {
 *         Name = "example-topic",
 *         IngestionDataSourceSettings = new Gcp.PubSub.Inputs.TopicIngestionDataSourceSettingsArgs
 *         {
 *             AwsKinesis = new Gcp.PubSub.Inputs.TopicIngestionDataSourceSettingsAwsKinesisArgs
 *             {
 *                 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 = "[email protected]",
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/pubsub"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := pubsub.NewTopic(ctx, "example", &pubsub.TopicArgs{
 * 			Name: pulumi.String("example-topic"),
 * 			IngestionDataSourceSettings: &pubsub.TopicIngestionDataSourceSettingsArgs{
 * 				AwsKinesis: &pubsub.TopicIngestionDataSourceSettingsAwsKinesisArgs{
 * 					StreamArn:         pulumi.String("arn:aws:kinesis:us-west-2:111111111111:stream/fake-stream-name"),
 * 					ConsumerArn:       pulumi.String("arn:aws:kinesis:us-west-2:111111111111:stream/fake-stream-name/consumer/consumer-1:1111111111"),
 * 					AwsRoleArn:        pulumi.String("arn:aws:iam::111111111111:role/fake-role-name"),
 * 					GcpServiceAccount: pulumi.String("[email protected]"),
 * 				},
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.pubsub.Topic;
 * import com.pulumi.gcp.pubsub.TopicArgs;
 * import com.pulumi.gcp.pubsub.inputs.TopicIngestionDataSourceSettingsArgs;
 * import com.pulumi.gcp.pubsub.inputs.TopicIngestionDataSourceSettingsAwsKinesisArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var example = new Topic("example", TopicArgs.builder()
 *             .name("example-topic")
 *             .ingestionDataSourceSettings(TopicIngestionDataSourceSettingsArgs.builder()
 *                 .awsKinesis(TopicIngestionDataSourceSettingsAwsKinesisArgs.builder()
 *                     .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("[email protected]")
 *                     .build())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: gcp:pubsub:Topic
 *     properties:
 *       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: [email protected]
 * ```
 * 
 * ## 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}}
 * ```
 * ```sh
 * $ pulumi import gcp:pubsub/topic:Topic default {{project}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:pubsub/topic:Topic default {{name}}
 * ```
 */
public class Topic internal constructor(
    override val javaResource: com.pulumi.gcp.pubsub.Topic,
) : KotlinCustomResource(javaResource, TopicMapper) {
    /**
     * All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
     */
    public val effectiveLabels: Output>
        get() = javaResource.effectiveLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * Settings for ingestion from a data source into this topic.
     * Structure is documented below.
     */
    public val ingestionDataSourceSettings: Output?
        get() = javaResource.ingestionDataSourceSettings().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> topicIngestionDataSourceSettingsToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * 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/*`
     * */*/*/*/
     */
    public val kmsKeyName: Output?
        get() = javaResource.kmsKeyName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * 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 `effective_labels` for all of the labels present on the resource.
     */
    public val labels: Output>?
        get() = javaResource.labels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * 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.
     */
    public val messageRetentionDuration: Output?
        get() = javaResource.messageRetentionDuration().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * 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.
     */
    public val messageStoragePolicy: Output
        get() = javaResource.messageStoragePolicy().applyValue({ args0 ->
            args0.let({ args0 ->
                topicMessageStoragePolicyToKotlin(args0)
            })
        })

    /**
     * Name of the topic.
     * - - -
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * The combination of labels configured directly on the resource
     * and default labels configured on the provider.
     */
    public val pulumiLabels: Output>
        get() = javaResource.pulumiLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * Settings for validating messages published against a schema.
     * Structure is documented below.
     */
    public val schemaSettings: Output
        get() = javaResource.schemaSettings().applyValue({ args0 ->
            args0.let({ args0 ->
                topicSchemaSettingsToKotlin(args0)
            })
        })
}

public object TopicMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.pubsub.Topic::class == javaResource::class

    override fun map(javaResource: Resource): Topic = Topic(
        javaResource as
            com.pulumi.gcp.pubsub.Topic,
    )
}

/**
 * @see [Topic].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [Topic].
 */
public suspend fun topic(name: String, block: suspend TopicResourceBuilder.() -> Unit): Topic {
    val builder = TopicResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [Topic].
 * @param name The _unique_ name of the resulting resource.
 */
public fun topic(name: String): Topic {
    val builder = TopicResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy