Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add grafana terraform definition and comment for accessing key #287

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions grafana/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions grafana/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
terraform {
r33drichards marked this conversation as resolved.
Show resolved Hide resolved
required_providers {
grafana = {
source = "grafana/grafana"
}
}
}

variable "prefix" {
type = string
default = "e2b-"
}

variable "grafana_cloud_access_policy_token_secret_name" {
type = string
description = <<EOT
The name of the secret in GCP Secret Manager that contains the Grafana cloud access policy token.

should have permissions:
- stacks read write delete
- stack-service-accounts write
EOT

default = "${var.prefix}grafana-cloud-access-policy-token"
}

data "google_secret_manager_secret_version" "grafana_cloud_access_policy_token" {
secret = var.grafana_cloud_access_policy_token_secret_name
}

// Step 1: Create a stack
provider "grafana" {
alias = "cloud"
cloud_access_policy_token = data.google_secret_manager_secret_version.grafana_cloud_access_policy_token.secret_data
}

resource "grafana_cloud_stack" "my_stack" {
provider = grafana.cloud

name = "${var.prefix}stack"
slug = "${var.prefix}stack"
region_slug = "us"
}

// Step 2: Create a service account and key for the stack
resource "grafana_cloud_stack_service_account" "cloud_sa" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really needed, it seems to me you only need to create Access Policy token
terraform resource

provider = grafana.cloud
stack_slug = grafana_cloud_stack.my_stack.slug

name = "${var.prefix}otel-collector-service-account"
role = "Admin"
is_disabled = false
}

resource "grafana_cloud_stack_service_account_token" "cloud_sa" {
provider = grafana.cloud
stack_slug = grafana_cloud_stack.my_stack.slug

name = "${var.prefix}stack-service-account-token"
service_account_id = grafana_cloud_stack_service_account.cloud_sa.id
}
9 changes: 9 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,12 @@ module "nomad" {
# Redis
redis_port = var.redis_port
}


module "grafana" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it just as a separate module, it's only optional module and it can become very annoying

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, then maybe in the makefile have it be like make plan-grafana and make apply-grafana
?

source = "./grafana"

prefix = var.prefix


}
Loading