Skip to content
Last9 named a Gartner Cool Vendor in AI for SRE Observability for 2025! Read more →
Last9

Terraform Provider

Manage Last9 resources as Infrastructure as Code using the official Terraform provider

The Last9 Terraform Provider enables Infrastructure as Code (IaC) management of Last9 resources. You can version control, review, and automate the deployment of alerts, notification channels, and ingestion rules.

Prerequisites

  1. Terraform v1.0 or later installed
  2. A Last9 account with access to the API Access page
  3. API tokens generated from the API Access page (see Getting Started with API)

Installation

Add the provider to your Terraform configuration:

terraform {
required_providers {
last9 = {
source = "last9/last9"
version = "~> 0.2"
}
}
}

Run terraform init to download the provider.

Configuration

Configure the provider with your Last9 credentials. You can use either refresh tokens (recommended) or direct access tokens.

Refresh tokens automatically handle token expiration and renewal:

provider "last9" {
refresh_token = var.last9_refresh_token
delete_refresh_token = var.last9_delete_refresh_token
org = var.last9_org
api_base_url = "https://app.last9.io"
}

Using Direct Access Tokens

For simpler setups where you manage token refresh manually:

provider "last9" {
api_token = var.last9_api_token
delete_token = var.last9_delete_token
org = var.last9_org
api_base_url = "https://app.last9.io"
}

Environment Variables

All provider arguments can be set via environment variables:

ArgumentEnvironment VariableDescription
refresh_tokenLAST9_REFRESH_TOKENRefresh token for read/write operations
delete_refresh_tokenLAST9_DELETE_REFRESH_TOKENRefresh token for delete operations
api_tokenLAST9_API_TOKENDirect access token
delete_tokenLAST9_DELETE_TOKENDelete access token
orgLAST9_ORGOrganization slug
api_base_urlLAST9_API_BASE_URLAPI base URL

Available Resources

ResourceDescription
last9_entityAlert groups that contain metric-based alerts
last9_alertThreshold-based alerts on metrics
last9_drop_ruleDrop unwanted telemetry at ingestion layer
last9_forward_ruleForward telemetry to external destinations
last9_scheduled_search_alertLog-based alerts using scheduled searches
last9_notification_channelNotification destinations for alerts

Data Sources

Data SourceDescription
last9_entityQuery existing alert group by ID or external_ref
last9_notification_destinationQuery existing notification destination by ID or name

Example Usage

Here’s a basic example that creates a Slack notification channel and a drop rule for debug logs:

# Notification channel
resource "last9_notification_channel" "slack" {
name = "platform-alerts"
type = "slack"
destination = "https://hooks.slack.com/services/xxx/yyy/zzz"
send_resolved = true
}
# Drop debug logs to reduce costs
resource "last9_drop_rule" "debug_logs" {
region = "ap-south-1"
name = "drop-debug-logs"
telemetry = "logs"
filters {
key = "attributes[\"level\"]"
value = "debug"
operator = "equals"
}
action {
name = "drop-matching"
}
}

For detailed schema documentation and more examples, see the Terraform Registry documentation.


Troubleshooting

Please get in touch with us on Discord or Email if you have any questions.