Skip to content

Example repository with a Grafana dashboard defined with Terraform grafana/schemas provider and deployed with grafana/grafana provider

Notifications You must be signed in to change notification settings

joanlopez/terraform-grafana-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Grafana example

Looking for building your own example?

If you're a learning-by-doing kind of person, you can follow the steps below to build your own example.

Pre-requisites

First of all, you need to have these tools up and running before starting:

Step by step

  1. Create a main.tf file with a main definition:

    terraform {
      required_providers {
        schemas = {
          source  = "grafana/schemas"
          version = "0.2.0"
        }
    
        grafana = {
          source  = "grafana/grafana"
          version = "2.1.0"
        }
      }
    }
    
    provider "grafana" {
      url  = var.GRAFANA_URL
      auth = var.GRAFANA_TOKEN
    }
  2. Create a vars.tf file with the variables' definition (will be read from environment):

    variable "GRAFANA_URL" {
      type        = string
      description = "Fully qualified domain name of your Grafana instance."
    }
    
    variable "GRAFANA_TOKEN" {
      type        = string
      description = "Basic auth password or API token."
    }
  3. Initialize a new Terraform working directory:

    terraform init
  4. Create a resources.tf file with a basic dashboard and the resource definition:

    data "schemas_core_dashboard" "example" {
      title = "Terraform example"
      description = "Example dashboard built with Terraform"
    }
    
    resource "grafana_dashboard" "example" {
      config_json = data.schemas_core_dashboard.example.rendered_json
    }
  5. Set up Grafana and Terraform auth as Actions secrets:

    • GRAFANA_URL with the root url of your instance
    • GRAFANA_TOKEN with your service account token
    • TF_API_TOKEN with your Terraform Cloud API token

    Additionally, you may want to set up the following variables:

    • TF_CLOUD_ORGANIZATION with the id of your Terraform cloud organization
    • TF_WORKSPACE with the id of your Terraform cloud workspace

Contribute

Have you detected a typo or something incorrect, and you are willing to contribute?

Please, open a pull request, and I'll be happy to review it.

About

Example repository with a Grafana dashboard defined with Terraform grafana/schemas provider and deployed with grafana/grafana provider

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages