confluent_schema
describes a Schema data source.
provider "confluent" {
cloud_api_key = var.confluent_cloud_api_key # optionally use CONFLUENT_CLOUD_API_KEY env var
cloud_api_secret = var.confluent_cloud_api_secret # optionally use CONFLUENT_CLOUD_API_SECRET env var
}
data "confluent_schema" "purchase-v1" {
schema_registry_cluster {
id = confluent_schema_registry_cluster.essentials.id
}
rest_endpoint = confluent_schema_registry_cluster.essentials.rest_endpoint
subject_name = "proto-purchase-value"
schema_identifier = 10001
credentials {
key = "<Schema Registry API Key for confluent_schema_registry_cluster.essentials>"
secret = "<Schema Registry API Secret for confluent_schema_registry_cluster.essentials>"
}
}
output "schema" {
value = data.confluent_schema.purchase-v1.schema
}
provider "confluent" {
schema_registry_id = var.schema_registry_id # optionally use SCHEMA_REGISTRY_ID env var
schema_registry_rest_endpoint = var.schema_registry_rest_endpoint # optionally use SCHEMA_REGISTRY_REST_ENDPOINT env var
schema_registry_api_key = var.schema_registry_api_key # optionally use SCHEMA_REGISTRY_API_KEY env var
schema_registry_api_secret = var.schema_registry_api_secret # optionally use SCHEMA_REGISTRY_API_SECRET env var
}
data "confluent_schema" "purchase-v1" {
subject_name = "proto-purchase-value"
schema_identifier = 10001
}
output "schema" {
value = data.confluent_schema.purchase-v1.schema
}
The following arguments are supported:
schema_registry_cluster
- (Optional Configuration Block) supports the following:
id
- (Required String) The ID of the Schema Registry cluster, for example, lsrc-abc123
.rest_endpoint
- (Optional String) The REST endpoint of the Schema Registry cluster, for example, https://psrc-00000.us-central1.gcp.confluent.cloud:443
).credentials
(Optional Configuration Block) supports the following:
key
- (Required String) The Schema Registry API Key.secret
- (Required String, Sensitive) The Schema Registry API Secret.subject_name
- (Required String) The name of the subject (in other words, the namespace), representing the subject under which the schema will be registered, for example, test-subject
. Schemas evolve safely, following a compatibility mode defined, under a subject name.schema_identifier
- (Required Integer) The globally unique ID of the Schema, for example, 100003
. If the same schema is registered under a different subject, the same identifier will be returned. However, the version
of the schema may be different under different subjects.In addition to the preceding arguments, the following attributes are exported:
id
- (Required String) The ID of the Schema, in the format <Schema Registry cluster ID>/<Subject name>/<Schema identifier>
, for example, lsrc-abc123/test-subject/100003
.format
- (Required String) The format of the schema. Accepted values are: AVRO
, PROTOBUF
, and JSON
.schema
- (Required String) The schema string, for example, file("./schema_version_1.avsc")
.schema_reference
- (Optional List) The list of referenced schemas (see Schema References for more details):
name
- (Required String) The name of the subject, representing the subject under which the referenced schema is registered.subject_name
- (Required String) The name for the reference. (For Avro Schema, the reference name is the fully qualified schema name, for JSON Schema it is a URL, and for Protobuf Schema, it is the name of another Protobuf file.)version
- (Required Integer) The version, representing the exact version of the schema under the registered subject.version
- (Required Integer) The version of the Schema, for example, 4
.metadata
- (Optional Block) See here for more details. Supports the following:
properties
- (Optional Map) The custom properties to set:
name
- (Required String) The setting name.value
- (Required String) The setting value.tags
- (Optional List of Blocks) supports the following:
key
- (Required String) The setting name.value
- (Required List of Strings) The list of tags.sensitive
- (Optional List of Strings) A list of metadata properties to be encrypted.ruleset
- (Optional Block) The list of schema rules. See Data Contracts for Schema Registry for more details. For example, these rules can enforce that a field that contains sensitive information must be encrypted, or that a message containing an invalid age must be sent to a dead letter queue.
domain_rules
- (Optional List of Blocks) supports the following:
name
- (Optional String) A user-defined name that can be used to reference the rule.doc
- (Optional String) An optional description.kind
- (Optional String) Either CONDITION
or TRANSFORM
.mode
- (Optional String) The mode of the rule.type
- (Optional String) The type of rule, which invokes a specific rule executor, such as Google Common Expression Language (CEL) or JSONata.expr
- (Optional String) The body of the rule, which is optional.on_success
- (Optional String) An optional action to execute if the rule succeeds, otherwise the built-in action type NONE is used. For UPDOWN and WRITEREAD rules, one can specify two actions separated by commas, such as “NONE,ERROR” for a WRITEREAD rule. In this case NONE applies to WRITE and ERROR applies to READ.on_failure
- (Optional String) An optional action to execute if the rule fails, otherwise the built-in action type ERROR is used. For UPDOWN and WRITEREAD rules, one can specify two actions separated by commas, as mentioned above.tags
- (Optional String List) The tags to which the rule applies, if any.params
- (Optional Configuration Block) A set of static parameters for the rule, which is optional. These are key-value pairs that are passed to the rule.