# Dynatrace Dashboard (Grail) via terraform

**URL:** <https://community.dynatrace.com/t/dynatrace-dashboard-grail-via-terraform/48000>\
**Category:** Dynatrace Tips\
**Tags:** grail, terraform, dashboards\
**Created:** [September 26, 2024, 2:24pm UTC](https://community.dynatrace.com/t/dynatrace-dashboard-grail-via-terraform/48000 "2024-09-26T14:24:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kaayush](https://avatars.discourse-cdn.com/v4/letter/k/a587f6/32.png) [@Kaayush](https://community.dynatrace.com/u/Kaayush)\
**Post date:** [September 26, 2024, 2:24pm UTC](https://community.dynatrace.com/t/dynatrace-dashboard-grail-via-terraform/48000/1 "2024-09-26T14:24:20Z")

</div>

Hi, this is more of a YSK. It took me sometime to get the grail(swagger) dashboard to be deployed via Terraform. I have listed down a basic code in reply.

---

<div class="post-metadata">

**Author:** ![Kaayush](https://avatars.discourse-cdn.com/v4/letter/k/a587f6/32.png) [@Kaayush](https://community.dynatrace.com/u/Kaayush)\
**Post date:** [September 26, 2024, 2:28pm UTC](https://community.dynatrace.com/t/dynatrace-dashboard-grail-via-terraform/48000/2 "2024-09-26T14:28:50Z")

</div>

1. Create a grail dashboard on UI and download the json.

2. Terraform document link:&nbsp;[Terraform Registry](https://registry.terraform.io/providers/dynatrace-oss/dynatrace/latest/docs/resources/document)  
3. provider.tf

```markup
terraform {
    required_providers {
        dynatrace = {
            version = "~> 1.0"
            source = "dynatrace-oss/dynatrace"
        }
    }
}

provider "dynatrace" {
  dt_env_url = var.dynatrace_env_url
  dt_api_token = var.dynatrace_api_token

  automation_client_id = var.automation_client_id
  automation_client_secret = var.automation_client_secret
}

```

4. variables.tf

```markup
variable "dynatrace_env_url" {
  description = "The ENV URL for your Dynatrace environment"
  type = string
}

variable "dynatrace_api_token" {
  description = "The API token for your Dynatrace environment"
  type = string
  sensitive = true
}

variable "automation_client_id" {
  description = "The client ID for automation and swagger UI dashboard"
  type = string
}

variable "automation_client_secret" {
  description = "The client secret for automation and swagger UI dashboard"
  type = string
  sensitive = true
}

```

5. swagger\_dashboard.tf

```markup
resource "dynatrace_document" "alb_example_tf" {
  type = "dashboard"
  name = "ALB Monitoring TF"
  private = false
  content = file(format("%s/alb_monitoring.json", path.module))
}

```

**DON’T FORGET TO ADD** `private: false`, otherwise only the owner(user who created automation automation secret) can view the dashboard.&nbsp;  
You can change owner to yours by setting `owner: UUID` in resource block.
