Schema

class Schema : KotlinCustomResource

A schema is a format that messages must follow, creating a contract between publisher and subscriber that Pub/Sub will enforce. To get more information about Schema, see:

Example Usage

Pubsub Schema Basic

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 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()
.definition("""
{
"type" : "record",
"name" : "Avro",
"fields" : [
{
"name" : "StringField",
"type" : "string"
},
{
"name" : "IntField",
"type" : "int"
}
]
}
""")
.type("AVRO")
.build());
}
}

Pubsub Schema Protobuf

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 com.pulumi.resources.CustomResourceOptions;
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 exampleSchema = new Schema("exampleSchema", SchemaArgs.builder()
.type("PROTOCOL_BUFFER")
.definition("""
syntax = "proto3";
message Results {
string message_request = 1;
string message_response = 2;
string timestamp_request = 3;
string timestamp_response = 4;
} """)
.build());
var exampleTopic = new Topic("exampleTopic", TopicArgs.builder()
.schemaSettings(TopicSchemaSettingsArgs.builder()
.schema("projects/my-project-name/schemas/example")
.encoding("JSON")
.build())
.build(), CustomResourceOptions.builder()
.dependsOn(exampleSchema)
.build());
}
}

Import

Schema can be imported using any of these accepted formats

$ pulumi import gcp:pubsub/schema:Schema default projects/{{project}}/schemas/{{name}}
$ pulumi import gcp:pubsub/schema:Schema default {{project}}/{{name}}
$ pulumi import gcp:pubsub/schema:Schema default {{name}}

Properties

Link copied to clipboard
val definition: Output<String>?

The definition of the schema. This should contain a string representing the full definition of the schema that is a valid schema definition of the type specified in type.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val name: Output<String>

The ID to use for the schema, which will become the final component of the schema's resource name.

Link copied to clipboard
val project: Output<String>

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val type: Output<String>?

The type of the schema definition Default value is TYPE_UNSPECIFIED. Possible values are: TYPE_UNSPECIFIED, PROTOCOL_BUFFER, AVRO.

Link copied to clipboard
val urn: Output<String>