Manage your N9 resources with Terraform
Reading time: 0 minute(s) (0 words)
See how to manage your Nobl9 resources with the Nobl9 Terraform provider.
Once you've checked all previous steps, you can plan, create and manage Nobl9 resources in one Terraform configuration file:
resource "nobl9_project" "this" {
display_name = "Test Terraform"
name = "test-terraform"
description = "An example terraform project"
}
resource "nobl9_service" "this" {
name = "foo-front-page"
project = nobl9_project.this.name
display_name = "${nobl9_project.this.display_name} Front Page"
description = "Front page service"
}
resource "nobl9_agent" "terraform-amz-prom" {
name = "terraform-amz-prom"
project = nobl9_project.this.name
source_of = ["Metrics", "Services"]
agent_type = "amazon_prometheus"
amazon_prometheus_config {
url = "http://web.net"
region = "eu-central-1"
}
}
resource "nobl9_slo" "this" {
name = "${nobl9_project.this.name}-latency"
service = nobl9_service.this.name
budgeting_method = "Occurrences"
project = nobl9_project.this.name
label {
key = "env"
values = ["dev", "prod"]
}
label {
key = "team"
values = ["red"]
}
# alert_policies = [
# "foo-front-page-latency"
# ]
time_window {
unit = "Day"
count = 30
is_rolling = true
}
objective {
name = "tf-objective-1"
target = 0.99
display_name = "OK"
value = 2000
op = "gte"
raw_metric {
query {
amazon_prometheus {
promql = <<EOT
latency_west_c7{code="ALL",instance="localhost:3000",job="prometheus",service="global-count"}
EOT
}
}
}
}
indicator {
name = nobl9_agent.terraform-amz-prom.name
project = nobl9_project.this.name
kind = "Agent"
}
}
Well done! You can now create and manage Nobl9 resources with the Nobl9 Terraform provider!