Skip to content

Configure Grafana with Terraform

This guide shows you how to configure Grafana settings and dashboards with the Grafana Terraform provider.

Before you begin

You need a Grafana workspace.

Step 1: Create a stack for Grafana settings

ok scaffold observability-grafana-settings
cd observability-grafana-settings

Step 2: Remove the default stack configuration


Step 3: Set up the module

ok get-template ""

# Configure the template
export TEAM_NAME=$(yq $ENV_FILE)
export ENVIRONMENT=$(yq .metadata.environment $ENV_FILE) 
export AWS_REGION=$(yq .aws.region $ENV_FILE)
export AWS_ACCOUNT_ID=$(yq .aws.accountID $ENV_FILE)
export STATE_NAME=$(basename $(pwd))

rm ""

ok get-template
ok get-template

mkdir templates
cd templates
ok get-template grafana-dashboard-golden-path.json.tpl
cd ..

Step 4: Apply the configuration

Initialize Terraform and apply the configuration:

terraform init
terraform apply

Grafana API key

A valid Grafana API key is required. You should already have one if you just completed the Grafana workspace guide. You don't have to do anything - it's loaded from SSM Parameter Store automatically.

What happens if the API key has expired?

If the API key has expired, terraform apply will fail. To resolve this issue, see common issues.


Open Grafana. You should be able to see a dashboard. For more settings, see the file in the module.

Next steps