Skip to content

Latest commit

 

History

History

recipe-16

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Recipe 16

The purpose of this recipe is to demonstrate the idea of "Dashboards-as-Code." It assumes you have terraform and az installed.

Step 1. Save your environment variables to a file called .env for az to use.

echo 'export TENANT_ID="..."' > .env
echo 'export SUBSCRIPTION_ID="..."' >> .env

Step 2. Feed your .env file to source so it can add your environment variables to your current shell session.

source .env

Step 3. Save your environment variables to a file called terraform.tfvars for terraform to use.

echo 'tenant_id = "..."' > terraform.tfvars
echo 'subscription_id = "..."' >> terraform.tfvars

Step 4. Enter the command below and authenticate when prompted.

az login --tenant "${TENANT_ID}" --use-device-code

Step 5. Enter the command sentence below so you can deploy an Azure Monitor Workspace instance.

az provider register --namespace Microsoft.Monitor

Step 6. Enter the command sentence below so you can deploy an Azure Managed Grafana instance.

az provider register --namespace Microsoft.Dashboard

Step 7. Change directories to terraform.

cd terraform

Step 8. Init the terraform directory (i.e., download all the external modules required).

terraform init

Step 9. Create a Terraform plan.

terraform plan

Step 10. Apply the Terraform plan you just created. When it's done, browser to the URL printed by terraform.

terraform apply

Troubleshooting

How to Remove a Specific Resource From Your Terraform State

terraform state list | grep GrafanaDashboard
terraform state rm module.GrafanaDashboard.grafana_dashboard.performance

How to Clear Your Terraform State

rm -rf .terraform && rm .terraform* && rm *.tfstate

References