Skip to content

cultureamp/terraform-provider-schemaregistry

Repository files navigation

Terraform logo

Terraform Provider for Schema Registry

Go report badge Release badge OpenSSF Scorecard

This provider is built using the Terraform Plugin Framework.

Requirements

  • Terraform 1.0+
  • Go 1.16+ (if you plan to build the provider from the source)

Building the Provider

If you want to build the provider from source, follow these steps:

  1. Clone the repository
  2. Run make tidy to install dependencies
  3. Build the provider using make build
  4. Run tests with make testacc

Testing the Provider

The acceptance tests rely on Testcontainers for Go (Redpanda) to provide a Schema Registry API. This has some limitations:

  • Redpanda only supports AVRO and PROTOBUF encoding, cannot test JSON schemas [1]

Using the Provider

If you're building the provider, follow the instructions to install it as a plugin. After placing it into your plugins directory, run terraform init to initialize it.

terraform {
  required_providers {
    schemaregistry = {
      source = "cultureamp/schemaregistry"
      version = "1.2.2"
    }
  }
}

provider "schemaregistry" {
  schema_registry_url = "https://schemaregistry.example.com"
  username            = "your-username"
  password            = "your-password"
}

resource "schemaregistry_schema" "example" {
  subject              = "example"
  schema_type          = "AVRO"
  compatibility_level  = "NONE"
  hard_delete          = false
  schema               = file("path/to/your/schema.avsc")

  # optional list of schema references
  references = [
    {
      name    = "ref-schema-name-1"
      subject = schemaregistry_schema.ref_schema_1.subject
      version = schemaregistry_schema.ref_schema_1.version
    },
  ]
}