A Terraform provider for Apache Pinot
terraform {
required_providers {
pinot = {
source = "azaurus1/pinot"
version = "0.2.0"
}
}
}
provider "pinot" {
controller_url = "http://localhost:9000" //required (can also be set via environment variable PINOT_CONTROLLER_URL)
auth_token = "YWRtaW46dmVyeXNlY3JldA" //optional (can also be set via environment variable PINOT_AUTH_TOKEN)
}
Example Schema:
resource "pinot_schema" "block_schema" {
schema_name = "ethereum_block_headers"
date_time_field_specs = [{
data_type = "LONG",
name = "block_timestamp",
format = "1:MILLISECONDS:EPOCH",
granularity = "1:MILLISECONDS",
transform_function = "ago('PT3H')"
}]
dimension_field_specs = [{
name = "block_number",
data_type = "INT",
not_null = true
},
{
name = "block_hash",
data_type = "STRING",
not_null = true,
transform_function = "jsonPathString(block, '$.block_hash')"
}]
metric_field_specs = [{
name = "block_difficulty",
data_type = "INT",
not_null = true
}]
}Example Table:
resource "pinot_table" "realtime_table" {
table_name = "realtime_ethereum_mainnet_block_headers_REALTIME"
table_type = "REALTIME"
table = file("realtime_table_example.json")Example User:
resource "pinot_user" "test" {
username = "user"
password = "password"
component = "BROKER"
role = "USER"
lifecycle {
ignore_changes = [password]
}
}This provider is built on the Terraform Plugin Framework. The template repository built on the Terraform Plugin SDK can be found at terraform-provider-scaffolding.
- run
go env GOBIN - Create
~/.terraformrcwith the following:
provider_installation {
dev_overrides {
"hashicorp.com/edu/pinot" = [Location of your GOBIN]
}
# For all other providers, install them directly from their origin provider
# registries as normal. If you omit this, Terraform will _only_ use
# the dev_overrides block, and so no other providers will be available.
direct {}
}- Clone the repository
- Enter the repository directory
- Build the provider using the Go
installcommand:
go installThis provider uses Go modules. Please see the Go documentation for the most up to date information about using Go modules.
To add a new dependency github.com/author/dependency to your Terraform provider:
go get github.com/author/dependency
go mod tidyThen commit the changes to go.mod and go.sum.
If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).
To compile the provider, run go install. This will build the provider and put the provider binary in the $GOPATH/bin directory.
To generate or update documentation, run go generate.
In order to run the full suite of Acceptance tests, run make testacc.
Note: Acceptance tests create real resources, and often cost money to run.
make testaccMany thanks to: