Skip to content
Thulasiraj Komminar edited this page Aug 21, 2024 · 2 revisions

Using the provider

Configure provider

terraform {
  required_providers {
    influxdb = {
      source  = "komminarlabs/influxdb3"
      version = "1.0.1"
    }
  }
}
provider "influxdb3" {
  account_id = "*******"
  cluster_id = "*******"
  token      = "*******"
  url        = "https://console.influxdata.com/api/v0"
}

Resources

Database:

resource "influxdb3_database" "signals" {
  name             = "signals"
  retention_period = 604800

  partition_template = [
    {
      type  = "tag"
      value = "line"
    },
    {
      type  = "tag"
      value = "station"
    },
    {
      type  = "time"
      value = "%Y-%m-%d"
    },
    {
      type = "bucket"
      value = jsonencode({
        "tagName" : "temperature",
        "numberOfBuckets" : 10
      })
    },
  ]
}

Token:

resource "influxdb3_token" "signals_rw" {
  description = "Read & Write access to signals database"

  permissions = [{
    action   = "read"
    resource = influxdb3_database.signals.name
    },
    {
      action   = "write"
      resource = influxdb3_database.signals.name
  }]
}

Data Sources

data "influxdb3_database" "signals" {
  name = "signals"
}

output "signals_bucket" {
  value = data.influxdb3_database.signals
}
Clone this wiki locally