-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
62 lines (56 loc) · 1.55 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
terraform {
required_version = "~> 1.2.0"
required_providers {
newrelic = {
source = "newrelic/newrelic"
version = "~> 3.2.0"
}
graphql = {
source = "sullivtr/graphql"
version = "2.5.3"
}
}
}
provider "newrelic" {
region = "US"
}
variable "accountId" { type = string }
variable "NEW_RELIC_API_KEY" { type = string }
provider "graphql" {
url = "https://api.newrelic.com/graphql"
headers = {
"API-Key" = var.NEW_RELIC_API_KEY
}
}
resource "graphql_mutation" "dashboard" {
mutation_variables = {
dashboard = templatefile("${path.module}/dashQueries/dash.json",{
DASHBOARD_NAME = "GraphQL Provider Dash"
widgets = [
{
name = "Amazon traffic"
accountId = var.accountId
whereClause ="where api like 'amazon%'"
},
{
name = "Google traffic"
accountId = var.accountId
whereClause ="where api like 'google%'"
}
]
}),
accountId = var.accountId
}
compute_mutation_keys = {
"guid" = "dashboardCreate.entityResult.guid" # The guid from the create is used for update, read, destroy
}
enable_remote_state_verification = false
compute_from_create = true
create_mutation = file("./dashQueries/createMutation.gql")
update_mutation = file("./dashQueries/updateMutation.gql")
delete_mutation = file("./dashQueries/deleteMutation.gql")
read_query = file("./dashQueries/readQuery.gql")
}
output "dashboard_guid" {
value=graphql_mutation.dashboard.computed_read_operation_variables.guid
}