Skip to main content

The Nobl9 Terraform provider

Reading time: 0 minute(s) (0 words)

Terraform is an infrastructure as code tool that lets you build, change, and version infrastructure safely and efficiently through a declarative configuration language. Using our dedicated Terraform provider, you can manage Nobl9 resources, controlling the lifecycle of your SLOs and other objects.

When to use?

We recommend Terraform over sloctl or a custom API integration when your workflow requires persistent state, execution plans, dependency ordering, or drift detection.

Overview

Nobl9 Terraform provider and its documentation are hosted in the official Terraform registry.

terraform
Image 1: Nobl9 Terraform documentation

Below you can see a minimal configuration which will create a Project, Service and an SLO. Generate user access keys or API keys to supply provider credentials. In order to execute this example run:

  • terraform init, this will fetch the Nobl9 provider and setup Terraform state
  • terraform apply, it creates the objects if they don't already exist and updates them otherwise
  • optionally, you can finish with terraform destroy to remove these objects

Choose your Nobl9 instance

main.tf
terraform {
required_providers {
nobl9 = {
source = "nobl9/nobl9"
}
}
}

provider "nobl9" {
client_id = "<CLIENT_ID>"
client_secret = "<CLIENT_SECRET>"


}

resource "nobl9_project" "this" {
name = "front-page"
}

resource "nobl9_service" "this" {
name = "front-page"
project = nobl9_project.this.name
}

resource "nobl9_slo" "slo_1" {
name = "front-page-latency"
service = nobl9_service.this.name
budgeting_method = "Occurrences"
project = nobl9_project.this.name

time_window {
unit = "Day"
count = 30
is_rolling = true
}

objective {
name = "good"
target = 0.99
value = 2000
op = "gte"
primary = true

raw_metric {
query {
prometheus {
promql = <<EOT
latency_west_c7{code="ALL",instance="localhost:3000",job="prometheus",service="glob_account"}
EOT
}
}
}
}

indicator {
name = "prometheus"
}
}
Check out these related guides and references: